Search Unity

  1. Check out the Unite LA keynote for updates on the Visual Effect Editor, the FPS Sample, ECS, Unity for Film and more! Watch it now!
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. Improved Prefab workflow (includes Nested Prefabs!), 2D isometric Tilemap and more! Get the 2018.3 Beta now.
    Dismiss Notice
  4. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice
  5. Want to see the most recent patch releases? Take a peek at the patch release page.
    Dismiss Notice

How to create an array of prefabs with editor available for each of them

Discussion in 'Scripting' started by Criperum, Nov 10, 2018 at 11:41 AM.

  1. Criperum

    Criperum

    Joined:
    Aug 7, 2014
    Posts:
    2
    Hello.
    I have a game object with an array for prefabs. I'm exposing this array to editor so i can drag-n-drop prefabs i want into this array. But those prefabs need to be adjusted using properties of scripts inside them. So my question is how to add those parameters to the array editor (i suppose i'm going to need custom editor)? I want to see those paramters under each array element so that i can expand and adjust them before launching. Also how can i filter those prefabs on drag stage so only prefabs with certain components (like scripts that inherit some base script) can be placed in that array?
     
  2. csofranz

    csofranz

    Joined:
    Apr 29, 2017
    Posts:
    134
    That's not how prefabs work. Prefabs are 'shrink-wrapped' and can't be changed when you place them into an array in editor. You need to pre-set the changes for each, then create a new prefab from that, and then add those to the array.
     
  3. Criperum

    Criperum

    Joined:
    Aug 7, 2014
    Posts:
    2
    What if I override drag-n-drop behaviour of editor so when i drop prefab on it i instantiate it and provide settings of gameobject to be set? Will this work?