Search Unity

Scripting nodes ...

Discussion in 'Scripting' started by jeremyace, May 31, 2006.

  1. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Hey,
    I need to fill an array with positions of nodes that are hand placed in the scene, but I am not sure how to go about it. I don't want to do it by hand as there will be many. The "problem" of sorts is each node has to be unique, and they have to be added to the array in a certain order.

    I haven't been able to figure out a good idea for it, but that might be partly because it's 5:31am and I have been programming all day er...yesterday. :)

    Any ideas on how to do this in a streamlined way?

    Thanks guys,
    -Jeremy
     
  2. Joachim_Ante

    Joachim_Ante

    Unity Technologies

    Joined:
    Mar 16, 2005
    Posts:
    5,203
    Use FindObjectsOfType or GameObject.FindGameObjectsWithTag.
    Then sort the returned list of objects by name.
    When creating the objects just use append numbers to the name to sort them.

    The fancy way of doing this would be adding a menu item, which generates the names correctly for you already. And attacheds any scripts or whatever you need.

    http://otee.dk//Documentation/ScriptReference/MenuItem.html
     
  3. jeremyace

    jeremyace

    Joined:
    Oct 12, 2005
    Posts:
    1,661
    Thanks Joe.
    -Jeremy