public static void DestroyImmediate(UdonSharpBehaviour behaviour) { UdonBehaviour udonBehaviour = UdonSharpEditorUtility.GetBackingUdonBehaviour(behaviour); if (udonBehaviour) { Undo.DestroyObjectImmediate(udonBehaviour); } Undo.DestroyObjectImmediate(behaviour); }
public static void DestroyImmediate(UdonSharpBehaviour behaviour) { UdonBehaviour udonBehaviour = UdonSharpEditorUtility.GetBackingUdonBehaviour(behaviour); if (udonBehaviour) { Undo.DestroyObjectImmediate(udonBehaviour); } UdonSharpEditorUtility.SetIgnoreEvents(true); try { Undo.DestroyObjectImmediate(behaviour); } finally { UdonSharpEditorUtility.SetIgnoreEvents(false); } }
public static UdonSharpBehaviour AddUdonSharpComponent(this GameObject gameObject, Type type) { if (type == typeof(UdonSharpBehaviour)) { throw new ArgumentException("Cannot add components of type 'UdonSharpBehaviour', you can only add subclasses of this type"); } if (!typeof(UdonSharpBehaviour).IsAssignableFrom(type)) { throw new ArgumentException("Type for AddUdonSharpComponent must be a subclass of UdonSharpBehaviour"); } UdonSharpBehaviour proxyBehaviour = (UdonSharpBehaviour)gameObject.AddComponent(type); UdonSharpEditorUtility.RunBehaviourSetup(proxyBehaviour); if (EditorApplication.isPlaying) { UdonSharpEditorUtility.GetBackingUdonBehaviour(proxyBehaviour).InitializeUdonContent(); } return(proxyBehaviour); }