Search Unity

  1. Unity 2019.1 beta is now available.
    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're looking for insight from anyone who has experience with game testing to help us better Unity. Take our survey here. If chosen to participate you'll be entered into a sweepstake to win an Amazon gift card.
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Unity 2018.3 is now released.
    Dismiss Notice
  6. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

How to call a method of my Custom Editor when I reset the target MonoBehavior ?

Discussion in 'Extensions & OnGUI' started by TracteurDim, Jan 21, 2019.

  1. TracteurDim

    TracteurDim

    Joined:
    Sep 7, 2017
    Posts:
    1
    Hi everybody !!

    I think it's my first thread on the forum ! I will be glad to read your answers.

    Here's my problem :
    I have a Custom Editor for a specific MonoBehavior.
    In my MonoBehavior script I have a simple method Reset() when player right-click -> Reset in the Inspector.
    It works perfectually, but I have a more complexe Custom Inspector, and I need to call a method to reset it. I can't find any way to do it... Do you have any idea ?
    Code (CSharp):
    1. /* Inherited MonoBehavior class */
    2. public void Reset()
    3. {
    4.       Anchors = new List<Anchor>();
    5.       Controls = new List<Vector3>();
    6.       AddAnchor();
    7.       AddAnchor();
    8.       //Maybe I can reset the custom inspector here ?
    9.  
    10.  }
    Or maybe I can watch for the monobehavior's reset directly inside my inspector ? But how ?

    Thank you !!
    Dim