/// <summary> /// Remove a JBehaviour /// </summary> /// <param name="jBehaviour"></param> public static void RemoveJBehaviour(JBehaviour jBehaviour) { if (Application.isEditor) { Tools.DestroyHotComponent(jBehaviour.gameObject, jBehaviour); } jBehaviour.Destroy(); }
/// <summary> /// Remove a JBehaviour /// </summary> /// <param name="jBehaviour"></param> public static void RemoveJBehaviour(JBehaviour jBehaviour) { if (Application.isEditor) { UnityEngine.Object.Destroy(GetJBehaviourInEditor(jBehaviour)); } jBehaviour.Destroy(); }
/// <summary> /// Get a JBehaviour in Editor /// </summary> /// <param name="jBehaviour"></param> /// <returns></returns> private static MonoBehaviourAdapter.Adaptor GetJBehaviourInEditor(JBehaviour jBehaviour) { var f = typeof(JBehaviour).GetField("_instanceID", BindingFlags.NonPublic); return(jBehaviour._gameObject.GetComponents <MonoBehaviourAdapter.Adaptor>() .ToList() .Find(a => a.isJBehaviour && f?.GetValue(a.ILInstance).ToString() == jBehaviour._instanceID)); }
/// <summary> /// Get a JUI on a gameObject /// 在gameObject上获取全部JUI /// </summary> /// <typeparam name="T"></typeparam> /// <param name="gameObject"></param> /// <returns></returns> public static JUI[] GetJUIs(this GameObject gameObject) { return(JBehaviour.GetJBehaviours <JUI>(gameObject)); }
/// <summary> /// Get a JUI on a gameObject /// 在gameObject上获取JUI /// </summary> /// <typeparam name="T"></typeparam> /// <param name="gameObject"></param> /// <returns></returns> public static JUI GetJUI(this GameObject gameObject) { return(JBehaviour.GetJBehaviour <JUI>(gameObject)); }
/// <summary> /// Create JUI on a gameObject /// 在gameObject上创建JUI /// </summary> /// <param name="gameObject"></param> /// <returns></returns> public static JUI CreateJUI(this GameObject gameObject) { return(JBehaviour.CreateOn <JUI>(gameObject, false)); }
/// <summary> /// Get all JBehaviour on a gameObject /// 在gameObject上获取全部JBehaviour /// </summary> /// <typeparam name="T"></typeparam> /// <param name="gameObject"></param> /// <returns></returns> public static T[] GetJBehaviours <T>(this GameObject gameObject) where T : JBehaviour { return(JBehaviour.GetJBehaviours <T>(gameObject)); }
/// <summary> /// Create a JBehaviour on a gameObject /// 在gameobject上创建JBehaviour /// </summary> /// <typeparam name="T"></typeparam> /// <param name="gameObject"></param> /// <param name="activeAfter"></param> /// <returns></returns> public static T CreateJBehaviour <T>(this GameObject gameObject, bool activeAfter = true) where T : JBehaviour { return(JBehaviour.CreateOn <T>(gameObject, activeAfter)); }
/// <summary> /// Remove a JUI /// 销毁JUI /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jBehaviour"></param> /// <returns></returns> public static void Remove(this JUI jUI) { JBehaviour.RemoveJBehaviour(jUI); }
/// <summary> /// Remove a JBehaviour /// 销毁JBehaviour /// </summary> /// <typeparam name="T"></typeparam> /// <param name="jBehaviour"></param> /// <returns></returns> public static void Remove(this JBehaviour jBehaviour) { JBehaviour.RemoveJBehaviour(jBehaviour); }