Search Unity

Adding and removing actions (like PlayMaker)

Discussion in 'Immediate Mode GUI (IMGUI)' started by AntFitch, Jun 29, 2016.

  1. AntFitch

    AntFitch

    Joined:
    Jan 31, 2012
    Posts:
    243
    I'm building a custom editor that lets you assign actions to game objects. Everything is working great, BUT, I've run into an annoying problem. Adding and removing actions is a pain in the butt. Right now, I manually add and remove them from a list (each is a c# class). In the editor, the user selects the action they want to use from a drop-down list.

    PlayMaker makes it easy to add and remove actions without resorting to putting all of the actions in a list (at least not by hand). Does anyone have any idea how this might be done? I don't really need code, just looking for discussion.
     
    Last edited: Jun 29, 2016
  2. IzzySoft

    IzzySoft

    Joined:
    Feb 11, 2013
    Posts:
    376
    How are you doing it right now?

    Are you attaching a certain script to the Game Object?
    Does that certain script use void OnEnable(), void OnDisable(), to attach/detach delegates/events/actions?
     
  3. AntFitch

    AntFitch

    Joined:
    Jan 31, 2012
    Posts:
    243
    Right now, each action has an ID. I have a drop-down list of names that is keyed to IDs assigned to the actions.

    I'll look into OnEnable() and OnDisable() to see if I can use these. I think I see where you might be going with this. :)