Esempio n. 1
0
        void DrawEditConditionButton()
        {
            if (m_AdjustableComponent == null)
            {
                return;
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUIUtils.DrawCheckboxFillerRect();

                var rect       = EditorGUILayout.GetControlRect(true, k_EditButtonHeight, styles.editButton);
                var buttonRect = new Rect(rect.xMin, rect.yMin, k_EditButtonWidth, k_EditButtonHeight);

                var labelContent = new GUIContent(k_ButtonLabel, k_ButtonTooltip);
                var labelSize    = GUI.skin.label.CalcSize(labelContent);

                var labelRect = new Rect(
                    buttonRect.xMax + k_SpaceBetweenLabelAndButton,
                    rect.yMin + (rect.height - labelSize.y) * .5f,
                    labelSize.x,
                    rect.height);

                var hasEditIcon   = MarsUIResources.instance.ConditionIcons.TryGetValue(target.GetType(), out var iconData);
                var buttonContent = hasEditIcon ? new GUIContent(iconData.Inactive.Icon, k_ButtonTooltip) : new GUIContent("Edit", k_ButtonTooltip);

                m_AdjustableComponent.Adjusting = GUI.Toggle(buttonRect, m_AdjustableComponent.Adjusting, buttonContent, styles.editButton);
                GUI.Label(labelRect, k_ButtonLabel);
            }

            EditorGUILayout.Space();
        }
        public override void OnInspectorGUI()
        {
            DrawDefaultInspector();

            var alignmentCondition = (AlignmentCondition)target;

            MarsCompareTool.DrawComponentControls(alignmentCondition);

            GUILayout.Space(5);
            using (new EditorGUILayout.HorizontalScope())
            {
                EditorGUIUtils.DrawCheckboxFillerRect();
                using (new EditorGUILayout.HorizontalScope())
                {
                    GUILayout.Label(k_AlignButtonContent);
                    GUILayout.FlexibleSpace();

                    if (GUILayout.Button("Horizontal", EditorStyles.miniButtonLeft))
                    {
                        RotateTargetsHorizontal();
                    }
                    if (GUILayout.Button("Vertical", EditorStyles.miniButtonMid))
                    {
                        RotateTargetsVertical();
                    }
                    if (GUILayout.Button("Default", EditorStyles.miniButtonRight))
                    {
                        RotateTargetsDefault();
                    }
                }
            }
        }
Esempio n. 3
0
        protected bool DrawChildOptions()
        {
            using (var check = new EditorGUI.ChangeCheckScope())
            {
                RefreshChildren();

                var child1 = (Proxy)m_Child1Property.objectReferenceValue;
                var child2 = (Proxy)m_Child2Property.objectReferenceValue;
                if (child1 == null || child2 == null)
                {
                    EditorGUIUtils.Warning(
                        "This relation has an invalid child reference, so it will not apply to the set");
                }

                var child1Index = k_ChildObjects.IndexOf(child1);
                var child2Index = k_ChildObjects.IndexOf(child2);

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUIUtils.DrawCheckboxFillerRect();
                    var newIndex = EditorGUILayout.Popup(child1Content, child1Index, k_ChildNames.ToArray());
                    if (newIndex == child2Index)
                    {
                        child2Index = child1Index;
                    }

                    child1Index = newIndex;
                }

                using (new EditorGUILayout.HorizontalScope())
                {
                    EditorGUIUtils.DrawCheckboxFillerRect();
                    var newIndex = EditorGUILayout.Popup(child2Content, child2Index, k_ChildNames.ToArray());
                    if (newIndex == child1Index)
                    {
                        child1Index = child2Index;
                    }

                    child2Index = newIndex;
                }

                m_Child1Property.objectReferenceValue = (child1Index >= 0) ? k_ChildObjects[child1Index] : null;
                m_Child2Property.objectReferenceValue = (child2Index >= 0) ? k_ChildObjects[child2Index] : null;
                child1Transform = relation.child1Transform;
                child2Transform = relation.child2Transform;

                return(check.changed);
            }
        }