Search Unity

OnValidate With Only User Changes?

Discussion in 'Editor & General Support' started by Matt-Face, Apr 10, 2017.

  1. Matt-Face

    Matt-Face

    Joined:
    Mar 24, 2013
    Posts:
    22
    What can i use to ignore the initial OnValidate() call when i first press play in Unity Editor?

    Code (CSharp):
    1. using System.Collections;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4.  
    5. public class ValidationTest : MonoBehaviour {
    6.     public float somefloat;
    7.     void Awake()
    8.     {
    9.         Debug.Log ("Awake...");
    10.     }
    11.     void Start () {
    12.         Debug.Log ("Start...");
    13.     }
    14.     void OnValidate()
    15.     {
    16.         Debug.Log ("Validating...");
    17.         if (Application.isPlaying == false && Application.isEditor == true) {
    18.             Debug.Log ("Because of the execution order, this check is ineffective for differentiating between an in editor change, and the assembly reload when the play button is pressed. What can i use instead?");
    19.         }
    20.     }
    21. }
    I'm guessing this is being called because of the assembly reload on play?

    not a game breaker, but i would be interested in how to ignore this if it is possible?

    Thanks