コード例 #1
0
        public object CreateConverter(ComponentEditor editor)
        {
            TransformPropertyConverter converter = new TransformPropertyConverter();

            converter.Component = (Transform)editor.Component;
            return(converter);
        }
コード例 #2
0
        public PropertyDescriptor[] GetProperties(ComponentEditor editor, object converterObj)
        {
            TransformPropertyConverter converter = (TransformPropertyConverter)converterObj;

            MemberInfo position          = Strong.MemberInfo((Transform x) => x.position);
            MemberInfo rotation          = Strong.MemberInfo((Transform x) => x.rotation);
            MemberInfo rotationConverted = Strong.MemberInfo((TransformPropertyConverter x) => x.Rotation);
            MemberInfo scale             = Strong.MemberInfo((Transform x) => x.localScale);

            return(new[]
            {
                new PropertyDescriptor("Position", editor.Component, position, position),
                new PropertyDescriptor("Rotation", converter, rotationConverted, rotation),
                new PropertyDescriptor("Scale", editor.Component, scale, scale)
            });
        }
コード例 #3
0
        private void Start()
        {
            GameObject          go               = EditorSelection.activeGameObject;
            ExposeToEditor      exposeToEditor   = go.GetComponent <ExposeToEditor>();
            HierarchyItem       hierarchyItem    = go.GetComponent <HierarchyItem>();
            HashSet <Component> ignoreComponents = new HashSet <Component>();

            if (exposeToEditor != null)
            {
                if (exposeToEditor.Colliders != null)
                {
                    for (int i = 0; i < exposeToEditor.Colliders.Length; ++i)
                    {
                        Collider collider = exposeToEditor.Colliders[i];
                        if (!ignoreComponents.Contains(collider))
                        {
                            ignoreComponents.Add(collider);
                        }
                    }
                }

                ignoreComponents.Add(exposeToEditor);
            }

            if (hierarchyItem != null)
            {
                ignoreComponents.Add(hierarchyItem);
            }

            InputName.text        = go.name;
            TogEnableDisable.isOn = go.activeSelf;

            InputName.onEndEdit.AddListener(OnEndEditName);
            TogEnableDisable.onValueChanged.AddListener(OnEnableDisable);
            Component[] components = go.GetComponents <Component>();
            //Component[] components = go.GetComponentsInChildren<Collider>();
            for (int i = 0; i < components.Length; ++i)
            {
                Component component = components[i];
                if (component == null)
                {
                    continue;
                }

                if (ignoreComponents.Contains(component))
                {
                    continue;
                }

                if ((component.hideFlags & HideFlags.HideInInspector) != 0)
                {
                    continue;
                }

                if (EditorsMap.IsObjectEditorEnabled(component.GetType()))
                {
                    GameObject editorPrefab = EditorsMap.GetObjectEditor(component.GetType());
                    if (editorPrefab != null)
                    {
                        ComponentEditor componentEditorPrefab = editorPrefab.GetComponent <ComponentEditor>();
                        if (componentEditorPrefab != null)
                        {
                            ComponentEditor editor = Instantiate(componentEditorPrefab);
                            editor.EndEditCallback = () =>
                            {
                                RuntimeEditorApplication.SaveSelectedObjects();
                            };
                            editor.transform.SetParent(ComponentsPanel, false);
                            editor.Component = component;
                        }
                        else
                        {
                            Debug.LogErrorFormat("editor prefab {0} does not have ComponentEditor script", editorPrefab.name);
                        }
                    }
                }
            }
        }