Exemplo n.º 1
0
 void AxisSelectButton(int index, ScenePlacementModule placementModule)
 {
     using (var change = new EditorGUI.ChangeCheckScope())
     {
         if (GUILayout.Toggle(currentAxis == index, Styles.axisIcons[index],
                              MarsEditorGUI.InternalEditorStyles.AppCommand) && change.changed)
         {
             placementModule.orientAxis = (AxisEnum)index;
             editorWindow.Close();
         }
     }
 }
Exemplo n.º 2
0
        static void DrawDropTargetButtonsGrid(Rect rect, ScenePlacementModule scenePlacementModule,
                                              GUIStyle firstStyle, GUIStyle midStyle, GUIStyle lastStyle, float buttonWidth, float buttonHeight)
        {
            var dropTargetsExist = InteractionTarget.AllTargets.Count > 0;

            using (new EditorGUI.DisabledScope(scenePlacementModule.isDragging || !dropTargetsExist))
            {
                var overrides    = scenePlacementModule.PlacementOverrides;
                var snapOverride = overrides.useSnapToPivotOverride;

                using (var change = new EditorGUI.ChangeCheckScope())
                {
                    bool snapToPivot;
                    bool orientToSurface;

                    using (new EditorGUI.DisabledScope(snapOverride))
                    {
                        var snapOverrideRect     = new Rect(rect.x, rect.y, buttonWidth, buttonHeight);
                        var pivotSnappingContent = !dropTargetsExist ? Styles.pivotSnappingNoDropContent :
                                                   snapOverride ? Styles.pivotSnappingOverrideContent : Styles.pivotSnappingContent;
                        snapToPivot = GUI.Toggle(snapOverrideRect, scenePlacementModule.snapToPivot,
                                                 pivotSnappingContent, firstStyle);
                    }

                    var orientOverride = overrides.useOrientToSurfaceOverride;

                    using (new EditorGUI.DisabledScope(orientOverride))
                    {
                        var orientOverrideRect     = new Rect(rect.x + buttonWidth, rect.y, buttonWidth, buttonHeight);
                        var orientToSurfaceContent = !dropTargetsExist ? Styles.orientToSurfaceNoDropContent :
                                                     orientOverride ? Styles.orientToSurfaceOverrideContent : Styles.orientToSurfaceContent;
                        orientToSurface = GUI.Toggle(orientOverrideRect, scenePlacementModule.orientToSurface,
                                                     orientToSurfaceContent, midStyle);
                    }

                    using (new EditorGUI.DisabledScope(!scenePlacementModule.orientToSurface))
                    {
                        var axisOverride = overrides.useAxisOverride;

                        using (new EditorGUI.DisabledScope(axisOverride))
                        {
                            var axisIndex      = (int)scenePlacementModule.orientAxis;
                            var stylesAxisIcon = !dropTargetsExist ? Styles.axisNoDropContent :
                                                 axisOverride ? Styles.axisOverrideContent : Styles.axisIcons[axisIndex];

                            if (s_AxisSelectWindow == null)
                            {
                                s_AxisSelectWindow = new AxisSelectWindow();
                            }

                            s_AxisSelectWindow.currentAxis = axisIndex;

                            var axisRect = new Rect(rect.x + buttonWidth * 2, rect.y, buttonWidth, buttonHeight);

                            if (GUI.Button(axisRect, stylesAxisIcon, lastStyle))
                            {
                                PopupWindow.Show(axisRect, s_AxisSelectWindow);
                                GUIUtility.ExitGUI();
                            }
                        }
                    }

                    if (change.changed)
                    {
                        scenePlacementModule.snapToPivot     = snapToPivot;
                        scenePlacementModule.orientToSurface = orientToSurface;
                    }
                }
            }
        }