/// <summary> /// 设置可视化父对象 /// </summary> /// <param name="self"></param> /// <param name="parent"></param> public static void SetParent(object self, object parent = null) { if (!Define.IsEditorMode) { return; } if (self == null) { return; } ECSView selfView = GetView(self); if (selfView == null) { _dic.RemoveByKey(self); return; } ECSView parentView = GetView(parent); if (parentView != null) { selfView.transform.parent = parentView.transform; } else { selfView.transform.parent = Root; } }
/// <summary> /// 根据可视化节点获取其组件 /// </summary> /// <param name="self"></param> /// <returns></returns> public static object GetComponent(ECSView self) { if (!Define.IsEditorMode) { return(null); } if (_dic.ContainsValue(self)) { return(_dic.GetKeyByValue(self)); } return(null); }
/// <summary> /// 销毁组件的可视化节点 /// </summary> /// <param name="self"></param> public static void DestroyView(object self) { if (!Define.IsEditorMode) { return; } if (_dic.ContainsKey(self)) { ECSView view = _dic.GetValueByKey(self); if (view != null) { DestroyImmediate(view.gameObject); } _dic.RemoveByKey(self); } }
/// <summary> /// 放入Pool操作,修改可视化节点到Pool节点下 /// </summary> /// <param name="self"></param> public static void ReturnPool(object self) { if (!Define.IsEditorMode) { return; } if (self == null) { return; } ECSView selfView = GetView(self); if (selfView == null) { _dic.RemoveByKey(self); return; } selfView.transform.parent = Pool; }