/// <summary>
        /// Configures the object.
        /// </summary>
        /// <param name="options">The configuration options.</param>
        public override void HelpInstantiate(params int[] options)
        {
            if (options.Contains(optionLabel))
            {
                DestroyImmediate(m_Icon.gameObject);
                m_ToggleBase.graphic         = m_Label;
                m_ToggleBase.graphicOffColor = MaterialColor.textDark;
            }
            else if (options.Contains(optionHasIcon))
            {
                DestroyImmediate(m_Label.gameObject);
                m_ToggleBase.graphic         = m_Icon;
                m_ToggleBase.graphicOffColor = MaterialColor.iconDark;
            }

            base.HelpInstantiate(options);

#if UNITY_EDITOR
            m_ToggleBase.EditorValidate();
#endif
        }
Exemplo n.º 2
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUI.BeginChangeCheck();
            {
                EditorGUILayout.PropertyField(m_Interactable);
            }
            if (EditorGUI.EndChangeCheck())
            {
                m_Toggle.interactable = m_Interactable.boolValue;
            }

            if (m_Graphic.objectReferenceValue != null)
            {
                EditorGUILayout.PropertyField(m_GraphicChangesWithToggleState);

                if (m_Graphic.objectReferenceValue.GetType() == typeof(Image) || m_Graphic.objectReferenceValue.GetType() == typeof(VectorImage))
                {
                    if (m_GraphicChangesWithToggleState.boolValue)
                    {
                        EditorGUILayout.PropertyField(m_ToggleOnIcon);
                        EditorGUILayout.PropertyField(m_ToggleOffIcon);
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(m_iconData);
                    }
                }
                else
                {
                    if (m_GraphicChangesWithToggleState.boolValue)
                    {
                        EditorGUILayout.PropertyField(m_ToggleOnLabel);
                        EditorGUILayout.PropertyField(m_ToggleOffLabel);
                    }
                    else
                    {
                        EditorGUILayout.PropertyField(m_LabelText);
                    }
                }
            }

            EditorGUI.BeginDisabledGroup(m_IsControllingChildren);
            {
                EditorGUILayout.PropertyField(m_AnimationDuration);

                EditorGUI.BeginChangeCheck();
                {
                    DrawFoldoutColors(ColorsSection);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    m_Toggle.EditorValidate();
                }
            }
            EditorGUI.EndDisabledGroup();

            EditorGUI.BeginChangeCheck();
            {
                DrawFoldoutComponents(ComponentsSection);
            }
            if (EditorGUI.EndChangeCheck())
            {
                m_Toggle.EditorValidate();
            }

            serializedObject.ApplyModifiedProperties();
        }