public void TrySetVariables() { editorTestingBehaviour.SetInspectorVariable("testInt", 100); editorTestingBehaviour.SetInspectorVariable("testString", "Hello World"); editorTestingBehaviour.SetInspectorVariable("testTransform", gameObject.transform); editorTestingBehaviour.SetInspectorVariable("testGameObject", gameObject); editorTestingBehaviour.SetInspectorVariable("testScriptReference", editorTestingBehaviour); }
/// <summary> /// resets a value to the prefab or original script value /// </summary> /// <param name="udonBehaviour"></param> /// <param name="symbolName">name of the variable visible in the inspector on the UdonBehaviour</param> /// <exception cref="ArgumentException">if udonBehaviour is invalid</exception> /// <exception cref="Exception">e.g. if the symbolName doesn't exist</exception> public static void ResetInspectorVariable(this UdonBehaviour udonBehaviour, string symbolName) { if (!udonBehaviour) { throw new ArgumentException("Invalid UdonBehaviour"); } // if (Application.IsPlaying(udonBehaviour)) // { // throw new Exception("Only edit mode is supported"); // } var programAsset = (UdonSharpProgramAsset)udonBehaviour.programSource; if (!programAsset) { throw new Exception("UdonBehaviour has no UdonSharpProgramAsset"); } programAsset.UpdateProgram(); udonBehaviour.SetInspectorVariable(symbolName, programAsset.GetPublicVariableDefaultValue(symbolName)); }