Search Unity

Add code-generated material and Sprite to Instantiated Prefab

Discussion in 'Prefabs' started by KungFuBrad, Apr 24, 2019.

  1. KungFuBrad

    KungFuBrad

    Joined:
    Apr 12, 2018
    Posts:
    9
    Greetings all,

    I'm looking to add an Instantiated Material and a new Sprite (both generated at runtime) to an Instantiated Prefab so I can use PrefabUtility.SaveAsAsset to accomplish having randomized assets at runtime.

    I've read that you do so (or at least did in the past) by something like ChildObject.transform.parent = InstantiatedPrefab.transform but Materials and Sprites don't have transforms.

    How would I do this via code?

    Thanks!