Example #1
0
        public void InitObject(GameObject gameObject, object data = null)
        {
            this.gameObject = gameObject;
            AutoReference();
            GameObject childGameObject = new GameObject(GetType().FullName);

            childGameObject.transform.SetParent(gameObject.transform);
            childGameObject.transform.localPosition = Vector3.zero;
            childGameObject.transform.localRotation = Quaternion.identity;
            childGameObject.transform.localScale    = Vector3.one;
            lccView              = childGameObject.AddComponent <LccView>();
            lccView.className    = GetType().FullName;
            lccView.type         = this;
            lccView.awake       += Awake;
            lccView.onEnable    += OnEnable;
            lccView.start       += Start;
            lccView.fixedUpdate += FixedUpdate;
            lccView.update      += Update;
            lccView.lateUpdate  += LateUpdate;
            lccView.onDisable   += OnDisable;
            lccView.onDestroy   += Destroy;
            if (gameObject.activeSelf)
            {
                Awake();
            }
            InitData(data);
        }
Example #2
0
        public override void OnInspectorGUI()
        {
            base.OnInspectorGUI();
            LccView lccView = (LccView)target;

            if (GUILayout.Button(lccView.className))
            {
                string directoryName = string.Empty;
                switch (Path.GetFileNameWithoutExtension(lccView.type.GetType().Assembly.ManifestModule.Name))
                {
                case "Unity.Model":
                    directoryName = "Scripts";
                    break;

                case "Unity.Hotfix":
                    directoryName = "Hotfix";
                    break;

                case "ILRuntime":
                    directoryName = "Hotfix";
                    break;
                }
                string   fileName  = lccView.className;
                string[] filePaths = Directory.GetFiles($"Assets/{directoryName}", "*.cs", SearchOption.AllDirectories);
                foreach (string item in filePaths)
                {
                    if (item.Substring(item.LastIndexOf(@"\") + 1) == $"{fileName}.cs")
                    {
                        EditorGUIUtility.PingObject(AssetDatabase.LoadAssetAtPath <TextAsset>(item));
                        AssetDatabase.OpenAsset(AssetDatabase.LoadAssetAtPath <Object>(item), 0);
                    }
                }
            }
            ObjectTypeUtil.Draw(lccView.type, 0);
        }
Example #3
0
        public void InitObject(GameObject gameObject, object data = null)
        {
            this.gameObject = gameObject;
            id = IdUtil.Generate();
            AutoReference();
            GameObject childGameObject = new GameObject(GetType().FullName);

            childGameObject.transform.SetParent(gameObject.transform);
            childGameObject.transform.localPosition = Vector3.zero;
            childGameObject.transform.localRotation = Quaternion.identity;
            childGameObject.transform.localScale    = Vector3.one;
            lccView           = childGameObject.AddComponent <LccView>();
            lccView.className = GetType().Name;
            lccView.type      = this;
            InitData(data);
            ObjectBaseEventSystem.Instance.Register(this);
        }
Example #4
0
 private void Destroy()
 {
     lccView    = null;
     gameObject = null;
     OnDestroy();
 }
Example #5
0
        public static T GetView <T>(GameObject gameObject) where T : AObjectBase
        {
            LccView lccView = gameObject.GetChildComponent <LccView>(typeof(T).FullName);

            return(lccView.GetType <T>());
        }