Search Unity

Custom Editor and Drawer issues.

Discussion in 'Scripting' started by Nemox, Feb 1, 2015.

  1. Nemox

    Nemox

    Joined:
    Feb 16, 2010
    Posts:
    396
    I'm having a lot of confusion over custom property drawers. I've tried many combinations of ideas but nothing has really worked out. A little conceptual guidance would really help. If I understand what it is I'm supposed to implement, I can do the scripting myself.

    To describe this as simply as possible, I have a Spell class and a SpellEffect class (or struct; whichever is necessary). The Spell class contains List<SpellEffect>. The SpellEffect class contains several variables (let's say a bool, a float, and a string).

    I want to make a custom editor for the Spell class. In the editor, I want to show the list of SpellEffects, and have each SpellEffect's bool and string be editable.

    Where do I start?
     
  2. hpjohn

    hpjohn

    Joined:
    Aug 14, 2012
    Posts:
    2,190
    CustomPropertyDrawer for the spelleffect alone should suffice, as long as spelleffect is serialisable
    http://docs.unity3d.com/ScriptReference/PropertyDrawer.html
    The example there pretty much covers your situation, class with a few properties

    Shouldnt need a custom editor for the Spell class