Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Custom Property Drawer

Discussion in 'Editor & General Support' started by Mike99, Jan 8, 2015.

  1. Mike99

    Mike99

    Joined:
    Dec 11, 2011
    Posts:
    160
    hi,

    i'd like to make a custom editor gui for a monobehaviour script like the one in the UI->Button component for the OnClick() where you can fill a list of object and select the method they contain.

    any idea how to do that ?
     
  2. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,183
    You have to define a CustomEditor. Read up on them here, or check out the official tutorial video here.
     
  3. Mike99

    Mike99

    Joined:
    Dec 11, 2011
    Posts:
    160
    i've seen those but what about exposing a script methods as in the UI buttons editor ?
     
  4. makeshiftwings

    makeshiftwings

    Joined:
    May 28, 2011
    Posts:
    3,350
    Those are "UnityEvents". You don't need a custom editor; you just need to add a UnityEvent variable to your script and it should show up automatically, then you can drag/drop an object onto it and select a method. Docs here: http://docs.unity3d.com/ScriptReference/Events.UnityEvent.html
     
  5. Mike99

    Mike99

    Joined:
    Dec 11, 2011
    Posts:
    160
    ok, thanks, i'm a bit confused between PropertyDrawer, CustomEditor, etc... but at least, i managed to get the methods of a script as a popup.