Search Unity

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

Discussion in 'Immediate Mode GUI (IMGUI)' started by TracteurDim, Jan 21, 2019.

  1. TracteurDim


    Sep 7, 2017
    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 ?
    10.  }
    Or maybe I can watch for the monobehavior's reset directly inside my inspector ? But how ?

    Thank you !!