Exemplo n.º 1
0
        public GameObject ToGameObject(GameObject parent)
        {
            GameObject obj;

            if (parent == null)
            {
                obj = new GameObject(SRML.Utils.ReflectionUtils.GetRelevantAssembly().GetName().Name.ToLower() + "." + Name);
                SRML.Utils.GameObjectUtils.Prefabitize(obj);
            }
            else
            {
                obj = new GameObject(Name);
                obj.transform.parent = parent.transform;
            }

            obj.transform.localPosition    = Position;
            obj.transform.localEulerAngles = Rotation;
            obj.transform.localScale       = Scale;

            if (actionOnAwake.Count > 0)
            {
                ActionOnAwake comp = obj.AddComponent <ActionOnAwake>();
                comp.actions = actionOnAwake;
            }

            if (actionOnStart.Count > 0)
            {
                ActionOnStart comp = obj.AddComponent <ActionOnStart>();
                comp.actions = actionOnStart;
            }

            foreach (ICreateComponent comp in components)
            {
                if (comp == null)
                {
                    continue;
                }

                comp.AddComponent(obj);
            }

            if (Tag != null)
            {
                obj.tag = Tag;
            }
            if (Layer != LayerMask.NameToLayer("Default"))
            {
                obj.layer = Layer;
            }

            foreach (GameObjectTemplate child in children)
            {
                child.ToGameObject(obj);
            }

            AfterChildren?.Invoke(obj);

            return(obj);
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            ActionOnStart c = (ActionOnStart)target;

            GUILayout.Space(8);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("enable"), true);
            if (c.enable)
            {
                GUILayout.Space(8);
                EditorGUILayout.PropertyField(serializedObject.FindProperty("onStart"), true);
            }

            serializedObject.ApplyModifiedProperties();
        }