Question by
yzhuan19 · Nov 17, 2021 at 11:05 PM ·
oninspectorgui
How to execute some functions under OnInspectorGUI() only once?
public override void OnInspectorGUI()
{
serializedObject.Update();
DisplayFields();
serializedObject.ApplyModifiedProperties(); // update the info in the actual object
ApplyBehaviors();
}
I have a script attached to the main camera (Script A), and I want to expand an array in Script A through some other script (Script B), and I was trying to do this under the function ApplyBehaviors()
. Since it's under OnInspectorGui()
, it gonna execute once every frame time, and my target array will expand much more times than I want it to.
Is there anyway that I can execute some code only once that I can expand my target array only once?
Comment