Exemplo n.º 1
0
 public Viewpoint(string name, SceneView view)
 {
     this.name     = name;
     settings      = new ViewSettings(view);
     visibleLayers = Tools.visibleLayers;
     lockedLayers  = Tools.lockedLayers;
 }
Exemplo n.º 2
0
 public Viewpoint(string name, ViewSettings settings, LayerMask visibleLayers, LayerMask lockedLayers, Action postAction = null)
 {
     this.name          = name;
     this.settings      = settings;
     this.visibleLayers = visibleLayers;
     this.lockedLayers  = lockedLayers;
     this.postAction    = postAction;
 }
        public static void ApplySettings(this SceneView view, ViewSettings settings, Viewpoint.Overrides overrides)
        {
            if (overrides.Contains(Viewpoint.Overrides.Is2D))
            {
                view.in2DMode = settings.is2D;
            }

            if (overrides.Contains(Viewpoint.Overrides.IsOrtho))
            {
                view.orthographic = settings.ortho;
            }

            if (overrides.Contains(Viewpoint.Overrides.Position))
            {
                view.pivot = settings.pivot;
                view.size  = settings.size;
            }

            if (overrides.Contains(Viewpoint.Overrides.Direction))
            {
                view.rotation = settings.rotation;
            }

            if (overrides.Contains(Viewpoint.Overrides.FieldOfView))
            {
                view.cameraSettings.fieldOfView = settings.fov;
            }

            if (overrides.Contains(Viewpoint.Overrides.CameraMode))
            {
                view.cameraMode = settings.mode;
            }

            if (overrides.Contains(Viewpoint.Overrides.Gizmos))
            {
                view.drawGizmos = settings.drawGizmos;
            }

            if (overrides.Contains(Viewpoint.Overrides.Lighting))
            {
                view.sceneLighting = settings.sceneLighting;
            }

            if (overrides.Contains(Viewpoint.Overrides.ViewStates))
            {
                view.sceneViewState.Copy(settings.sceneViewState);
            }

            if (overrides.Contains(Viewpoint.Overrides.Grid))
            {
                view.showGrid = settings.showGrid;
            }

            SceneView.RepaintAll();
        }
Exemplo n.º 4
0
        static Bookmarks()
        {
            instance = new Bookmarks();
            instance.builtin_viewpoints = new List <Viewpoint>();

            var allDisabled = new SceneView.SceneViewState();

            allDisabled.SetAllEnabled(false);

            var perspective_settings = new ViewSettings(Vector3.zero, Quaternion.Euler(30f, -50f, 0), 100f, false, 60f, false, SceneView.GetBuiltinCameraMode(DrawCameraMode.Textured), true, true, new SceneView.SceneViewState(), true);
            var perspective_view     = new Viewpoint("Perspective (Shaded)", perspective_settings, -1 ^ (1 << 5), 0, (Viewpoint.Overrides)(-1) ^ Viewpoint.Overrides.Position);

            instance.builtin_viewpoints.Add(perspective_view);

            var top_settings = new ViewSettings(Vector3.zero, Quaternion.LookRotation(Vector3.down, Vector3.forward), 100f, true, 60f, false, SceneView.GetBuiltinCameraMode(DrawCameraMode.Wireframe), true, false, allDisabled, true);
            var top_view     = new Viewpoint("Top (Wireframe, UI Hidden)", top_settings, -1 ^ (1 << 5), 0, (Viewpoint.Overrides)(-1) ^ Viewpoint.Overrides.Position);

            instance.builtin_viewpoints.Add(top_view);

            var front_settings = new ViewSettings(Vector3.zero, Quaternion.LookRotation(Vector3.forward, Vector3.up), 100f, true, 60f, false, SceneView.GetBuiltinCameraMode(DrawCameraMode.Wireframe), true, false, allDisabled, true);
            var front_view     = new Viewpoint("Front (Wireframe, UI Hidden)", front_settings, -1 ^ (1 << 5), 0, (Viewpoint.Overrides)(-1) ^ Viewpoint.Overrides.Position);

            instance.builtin_viewpoints.Add(front_view);

            var ui_settings = new ViewSettings(Vector3.zero, Quaternion.identity, 100f, true, 60f, true, SceneView.GetBuiltinCameraMode(DrawCameraMode.Textured), true, true, allDisabled, true);
            var ui_view     = new Viewpoint("2D (UI Only)", ui_settings, 0 ^ (1 << 5), 0, () =>
            {
                SceneView.lastActiveSceneView.FrameLayers(Tools.visibleLayers);
            });

            instance.builtin_viewpoints.Add(ui_view);

            instance.viewpoints = new List <Viewpoint>();
            instance.LoadFromJson(path);
            SceneView.duringSceneGui   += SceneView_duringSceneGui;
            EditorApplication.quitting += EditorApplication_quitting;
            EditorSceneManager.activeSceneChangedInEditMode += EditorSceneManager_activeSceneChangedInEditMode;

#if DISCOVERY_MENU
            HotBoxMenuItem hotBoxMenuItem = new HotBoxMenuItem("Views");
            hotBoxMenuItem.Refresh = () => { hotBoxMenuItem.menu = QuickAccessMenu(SceneView.lastActiveSceneView); };
            SceneViewHotBox.menuItems.Add("Views", hotBoxMenuItem);
#endif
        }
Exemplo n.º 5
0
 public void Save(SceneView view)
 {
     settings      = new ViewSettings(view);
     visibleLayers = Tools.visibleLayers;
     lockedLayers  = Tools.lockedLayers;
 }