Search Unity

  1. Unity 2018.3 is now released.
    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. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

Managing references to a custom class from a custom editor window

Discussion in 'Extensions & OnGUI' started by LochMessMonster, Apr 26, 2018.

  1. LochMessMonster


    Apr 26, 2018

    I am planning on creating a custom editor window (using C#) that is essentially a node editor. Each node will contain a list of custom class objects (called Trigger for now). The Trigger will be sort of similar to the Animator Trigger which is used for triggering animation states. Each node will actively monitor whether the listed Triggers have met the specified conditions. After all the Trigger conditions have been met, it will begin to call it's other functions.

    GameObjects in a scene will store a reference to these Trigger objects and the Trigger conditions will be fired off during run-time.

    I thought of creating a custom component that contains a list of Triggers. These components will be attached to GameObjects so that they can fire off the Triggers during run-time (using GetComponent() and then find the appropriate Trigger from the list). However I am not sure how to go about connecting the Triggers from the component to the nodes in the node editor.

    Could you please suggest a way of achieving this? Or perhaps is there a better way of managing the Trigger objects so a GameObject can find and store a reference to the Triggers without attaching a custom component?

    Thank you.
  2. Hosnkobf


    Aug 23, 2016
    I would probably make a Singleton (proabably a scriptable object to have it all serialized -- I use this one: ).
    that singleton either stores all triggers themselves or stores all graphs which in turn contain the triggers.

    From the MonoBehaviour you can then access that singleton to get the data you need.