Beispiel #1
0
        public static bool WillModelRender(CSGModel model)
        {
            // Is our model valid ...?
            if (!IsModelEditable(model))
            {
                return(false);
            }

#if UNITY_2018_3_OR_NEWER
            if (CSGPrefabUtility.AreInPrefabMode())
            {
                if (!CSGPrefabUtility.IsEditedInPrefabMode(model))
                {
                    return(false);
                }
            }
#endif
            // Does our model have a meshRenderer?
            if (model.IsRenderable)
            {
                // If so, is it shadow-only?
//				if (model.ShadowsOnly)
//				{
                // .. and do we need to show shadow-only surfaces?
//					return CSGSettings.ShowCastShadowsSurfaces;
//				}

                // Otherwise, it is always rendering (with the exception of manually hidden surfaces)
                return(true);
            }

            // Is it a trigger and are we showing triggers?
            if (model.IsTrigger && CSGSettings.ShowTriggerSurfaces)
            {
                return(true);
            }

            // Check if it's a collider and are we showing colliders?
            if (model.HaveCollider && CSGSettings.ShowColliderSurfaces)
            {
                return(true);
            }

            // Otherwise see if we're showing surfaces culled by the CSG process ...
            return(CSGSettings.ShowCulledSurfaces);
        }
Beispiel #2
0
        public static bool IsModelEditable(CSGModel model)
        {
            if (!model)
            {
                return(false);
            }

#if UNITY_2018_3_OR_NEWER && UNITY_EDITOR
            if (CSGPrefabUtility.AreInPrefabMode())
            {
                // Nested prefabs do not play nice with editing in scene, so it's best to edit them in prefab mode themselves
                // We only allow editing of nested prefabs when in prefab mode
                return(CSGPrefabUtility.IsEditedInPrefabMode(model));
            }
#endif
            return(model.isActiveAndEnabled);
        }
Beispiel #3
0
        static void OnEditModeSelectionSceneGUI()
        {
            CSG_GUIStyleUtility.InitStyles();
            if (CSG_GUIStyleUtility.brushEditModeNames == null ||
                CSG_GUIStyleUtility.brushEditModeNames.Length == 0)
            {
                return;
            }

            var oldSkin = GUI.skin;

            CSG_GUIStyleUtility.SetDefaultGUISkin();
            GUILayout.BeginHorizontal(CSG_GUIStyleUtility.ContentEmpty);
            {
                GUIStyle windowStyle = GUI.skin.window;

                float topBarSize = 20;
#if UNITY_2018_3_OR_NEWER
                if (CSGPrefabUtility.AreInPrefabMode())
                {
                    topBarSize += 25;
                }
#endif


                var bounds = new Rect(10, 10 + topBarSize, 500, 40);

                GUILayout.BeginArea(bounds, ContentTitleLabel, windowStyle);
                {
                    //GUILayout.Space(bounds.height);
                    Rect editModeBounds;

                    CSG_GUIStyleUtility.InitStyles();
                    EditorGUI.BeginChangeCheck();
                    var newEditMode = (ToolEditMode)CSG_EditorGUIUtility.ToolbarWrapped((int)EditModeManager.EditMode, ref editModeRects, out editModeBounds, CSG_GUIStyleUtility.brushEditModeContent, CSG_GUIStyleUtility.brushEditModeTooltips, yOffset: 20, areaWidth: bounds.width);
                    //var newEditMode = (ToolEditMode)GUILayout.Toolbar((int)CSGBrushEditorManager.EditMode, GUIStyleUtility.brushEditModeContent, GUIStyleUtility.brushEditModeTooltips);
                    if (EditorGUI.EndChangeCheck())
                    {
                        EditModeManager.EditMode = newEditMode;
                        CSG_EditorGUIUtility.RepaintAll();
                    }

                    var buttonArea = bounds;
                    buttonArea.x      = bounds.width - 17;
                    buttonArea.y      = 2;
                    buttonArea.height = 13;
                    buttonArea.width  = 13;
                    if (GUI.Button(buttonArea, GUIContent.none, "WinBtnClose"))
                    {
                        EditModeToolWindowSceneGUI.GetWindow();
                    }
                    TooltipUtility.SetToolTip(CSG_GUIStyleUtility.PopOutTooltip, buttonArea);

                    var versionWidth = CSG_GUIStyleUtility.versionLabelStyle.CalcSize(VersionLabel);
                    var versionArea  = bounds;
                    versionArea.x      = bounds.width - (17 + versionWidth.x);
                    versionArea.y      = 1;
                    versionArea.height = 15;
                    versionArea.width  = versionWidth.x;
                    GUI.Label(versionArea, VersionLabel, CSG_GUIStyleUtility.versionLabelStyle);
                }
                GUILayout.EndArea();

                int controlID = GUIUtility.GetControlID(SceneViewBrushEditorOverlayHash, FocusType.Keyboard, bounds);
                switch (Event.current.GetTypeForControl(controlID))
                {
                case EventType.MouseDown:       { if (bounds.Contains(Event.current.mousePosition))
                                                  {
                                                      GUIUtility.hotControl = controlID; GUIUtility.keyboardControl = controlID; EditorGUIUtility.editingTextField = false; Event.current.Use();
                                                  }
                                                  break; }

                case EventType.MouseMove:       { if (bounds.Contains(Event.current.mousePosition))
                                                  {
                                                      Event.current.Use();
                                                  }
                                                  break; }

                case EventType.MouseUp:         { if (GUIUtility.hotControl == controlID)
                                                  {
                                                      GUIUtility.hotControl = 0; GUIUtility.keyboardControl = 0; Event.current.Use();
                                                  }
                                                  break; }

                case EventType.MouseDrag:       { if (GUIUtility.hotControl == controlID)
                                                  {
                                                      Event.current.Use();
                                                  }
                                                  break; }

                case EventType.ScrollWheel: { if (bounds.Contains(Event.current.mousePosition))
                                              {
                                                  Event.current.Use();
                                              }
                                              break; }
                }
            }
            GUILayout.EndHorizontal();
            GUI.skin = oldSkin;
        }