Ejemplo n.º 1
0
        public override void Initialize()
        {
            base.Initialize();

            isActiveGetter = () => ((GameObject)Value).activeSelf;
            isActiveSetter = (value) => ((GameObject)Value).SetActive((bool)value);

            nameGetter = () => ((GameObject)Value).name;
            nameSetter = (value) =>
            {
                ((GameObject)Value).name = (string)value;
                NameRaw = Value.GetNameWithType();

                RuntimeHierarchy hierarchy = Inspector.ConnectedHierarchy;
                if (hierarchy)
                {
                    hierarchy.RefreshNameOf(((GameObject)Value).transform);
                }
            };

            tagGetter = () =>
            {
                GameObject go = (GameObject)Value;
                if (!go.CompareTag(currentTag))
                {
                    currentTag = go.tag;
                }

                return(currentTag);
            };
            tagSetter = (value) => ((GameObject)Value).tag = (string)value;

            layerProp = typeof(GameObject).GetProperty("layer");
        }
Ejemplo n.º 2
0
        protected override void GenerateElements()
        {
            if (components.Count == 0)
            {
                return;
            }

            CreateDrawer(typeof(bool), "Is Active", () => ((GameObject)Value).activeSelf, (value) => ((GameObject)Value).SetActive((bool)value));
            nameField = CreateDrawer(typeof(string), "Name", () => ((GameObject)Value).name, (value) =>
            {
                ((GameObject)Value).name = (string)value;
                NameRaw = Value.GetNameWithType();

                RuntimeHierarchy hierarchy = Inspector.ConnectedHierarchy;
                if (hierarchy != null)
                {
                    hierarchy.RefreshNameOf(((GameObject)Value).transform);
                }
            }) as StringField;
            tagField = CreateDrawer(typeof(string), "Tag", () =>
            {
                GameObject go = (GameObject)Value;
                if (!go.CompareTag(currentTag))
                {
                    currentTag = go.tag;
                }

                return(currentTag);
            }, (value) => ((GameObject)Value).tag = (string)value) as StringField;
            CreateDrawerForVariable(typeof(GameObject).GetProperty("layer"), "Layer");

            for (int i = 0, j = elements.Count; i < components.Count; i++)
            {
                InspectorField componentDrawer = CreateDrawerForComponent(components[i]);
                if (componentDrawer != null)
                {
                    if (j < componentsExpandedStates.Count && componentsExpandedStates[j] && componentDrawer is ExpandableInspectorField)
                    {
                        ((ExpandableInspectorField)componentDrawer).IsExpanded = true;
                    }

                    j++;
                }
            }

            if (nameField != null)
            {
                nameField.SetterMode = StringField.Mode.OnSubmit;
            }

            if (tagField != null)
            {
                tagField.SetterMode = StringField.Mode.OnSubmit;
            }

            componentsExpandedStates.Clear();
        }
Ejemplo n.º 3
0
        protected override void GenerateElements()
        {
            if (components.Count == 0)
            {
                return;
            }

            CreateDrawer(typeof(bool), "Is Active", () => ((GameObject)Value).activeSelf, (value) => ((GameObject)Value).SetActive((bool)value));
            nameField = CreateDrawer(typeof(string), "Name", () => ((GameObject)Value).name, (value) =>
            {
                ((GameObject)Value).name = (string)value;

                RuntimeHierarchy hierarchy = Inspector.ConnectedHierarchy;
                if (hierarchy != null)
                {
                    hierarchy.RefreshNameOf(((GameObject)Value).transform);
                }
            }) as StringField;
            tagField = CreateDrawer(typeof(string), "Tag", () =>
            {
                GameObject go = (GameObject)Value;
                if (!go.CompareTag(currentTag))
                {
                    currentTag = go.tag;
                }

                return(currentTag);
            }, (value) => ((GameObject)Value).tag = (string)value) as StringField;
            CreateDrawerForVariable(typeof(GameObject).GetProperty("layer"), "Layer");

            for (int i = 0; i < components.Count; i++)
            {
                CreateDrawerForComponent(components[i]);
            }

            if (nameField != null)
            {
                nameField.SetterMode = StringField.Mode.OnSubmit;
            }

            if (tagField != null)
            {
                tagField.SetterMode = StringField.Mode.OnSubmit;
            }
        }