Пример #1
0
        public void BuildEditor()
        {
            IComponentDescriptor componentDescriptor = GetComponentDescriptor();

            if (componentDescriptor != null)
            {
                m_converter = componentDescriptor.CreateConverter(this);
            }

            PropertyDescriptor[] descriptors = GetDescriptors(m_converter);
            if (descriptors == null || descriptors.Length == 0)
            {
                if (ExpanderGraphics != null)
                {
                    ExpanderGraphics.SetActive(false);
                }

                return;
            }

            if (ResetButton != null)
            {
                ResetButton.gameObject.SetActive(componentDescriptor != null ?
                                                 componentDescriptor.GetHeaderDescriptor(m_editor).ShowResetButton :
                                                 m_editor.ComponentEditorSettings.ShowResetButton);
            }

            if (EnabledEditor != null)
            {
                EnabledEditor.gameObject.SetActive(componentDescriptor != null ?
                                                   componentDescriptor.GetHeaderDescriptor(m_editor).ShowEnableButton :
                                                   m_editor.ComponentEditorSettings.ShowEnableButton);
            }

            if (Expander == null)
            {
                BuildEditor(componentDescriptor, descriptors);
            }
            else
            {
                if (componentDescriptor != null ? !componentDescriptor.GetHeaderDescriptor(m_editor).ShowExpander : !m_editor.ComponentEditorSettings.ShowExpander)
                {
                    Expander.isOn    = true;
                    Expander.enabled = false;
                }

                if (Expander.isOn)
                {
                    if (ExpanderGraphics != null)
                    {
                        ExpanderGraphics.SetActive(componentDescriptor != null ? componentDescriptor.GetHeaderDescriptor(m_editor).ShowExpander : m_editor.ComponentEditorSettings.ShowExpander);
                    }
                    BuildEditor(componentDescriptor, descriptors);
                }
            }
        }
Пример #2
0
        public void BuildEditor()
        {
            IComponentDescriptor componentDescriptor = GetComponentDescriptor();

            if (componentDescriptor != null)
            {
                m_converter = componentDescriptor.CreateConverter(this);
            }

            PropertyDescriptor[] descriptors = m_editorsMap.GetPropertyDescriptors(Component.GetType(), this, m_converter);
            if (descriptors == null || descriptors.Length == 0)
            {
                if (ExpanderGraphics != null)
                {
                    ExpanderGraphics.SetActive(false);
                }

                return;
            }

            ISettingsComponent     settingsComponent = IOC.Resolve <ISettingsComponent>();
            BuiltInWindowsSettings settings;

            if (settingsComponent == null)
            {
                settings = BuiltInWindowsSettings.Default;
            }
            else
            {
                settings = settingsComponent.BuiltInWindowsSettings;
            }

            if (ResetButton != null)
            {
                ResetButton.gameObject.SetActive(componentDescriptor != null ?
                                                 componentDescriptor.GetHeaderDescriptor(m_editor).ShowResetButton :
                                                 settings.Inspector.ComponentEditor.ShowResetButton);
            }

            if (RemoveButton != null)
            {
                bool showRemoveButton = componentDescriptor != null?
                                        componentDescriptor.GetHeaderDescriptor(m_editor).ShowRemoveButton:
                                        settings.Inspector.ComponentEditor.ShowRemoveButton;

                if (showRemoveButton)
                {
                    bool canRemove = m_project == null || m_project.ToAssetItem(Component.gameObject) == null;
                    if (!canRemove)
                    {
                        showRemoveButton = false;
                    }
                }

                RemoveButton.gameObject.SetActive(showRemoveButton);
            }

            if (EnabledEditor != null && EnabledProperty != null)
            {
                EnabledEditor.gameObject.SetActive(componentDescriptor != null ?
                                                   componentDescriptor.GetHeaderDescriptor(m_editor).ShowEnableButton :
                                                   settings.Inspector.ComponentEditor.ShowEnableButton);
            }

            if (Expander == null)
            {
                BuildEditor(componentDescriptor, descriptors);
            }
            else
            {
                if (componentDescriptor != null ? !componentDescriptor.GetHeaderDescriptor(m_editor).ShowExpander : !settings.Inspector.ComponentEditor.ShowExpander)
                {
                    Expander.isOn    = true;
                    Expander.enabled = false;
                }

                if (Expander.isOn)
                {
                    if (ExpanderGraphics != null)
                    {
                        ExpanderGraphics.SetActive(componentDescriptor != null ? componentDescriptor.GetHeaderDescriptor(m_editor).ShowExpander : settings.Inspector.ComponentEditor.ShowExpander);
                    }
                    BuildEditor(componentDescriptor, descriptors);
                }
            }
        }