-
-
Notifications
You must be signed in to change notification settings - Fork 473
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #677 from crest-ocean/feature/view-camera-property
Add camera property to ocean renderer
- Loading branch information
Showing
4 changed files
with
133 additions
and
68 deletions.
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
crest/Assets/Crest/Crest/Scripts/Helpers/Editor/EditorHelpers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
// Crest Ocean System | ||
|
||
// This file is subject to the MIT License as seen in the root of this folder structure (LICENSE) | ||
|
||
#if UNITY_EDITOR | ||
|
||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace Crest | ||
{ | ||
/// <summary> | ||
/// Provides general helper functions for the editor. | ||
/// </summary> | ||
public static class EditorHelpers | ||
{ | ||
static EditorWindow _lastGameOrSceneEditorWindow = null; | ||
|
||
/// <summary> | ||
/// Returns the scene view camera if the scene view is focused. | ||
/// </summary> | ||
public static Camera GetActiveSceneViewCamera() | ||
{ | ||
Camera sceneCamera = null; | ||
|
||
if (EditorWindow.focusedWindow != null && (EditorWindow.focusedWindow.titleContent.text == "Scene" || | ||
EditorWindow.focusedWindow.titleContent.text == "Game")) | ||
{ | ||
_lastGameOrSceneEditorWindow = EditorWindow.focusedWindow; | ||
} | ||
|
||
// If scene view is focused, use its camera. This code is slightly ropey but seems to work ok enough. | ||
if (_lastGameOrSceneEditorWindow != null && _lastGameOrSceneEditorWindow.titleContent.text == "Scene") | ||
{ | ||
var sceneView = SceneView.lastActiveSceneView; | ||
if (sceneView != null && !EditorApplication.isPlaying) | ||
{ | ||
sceneCamera = sceneView.camera; | ||
} | ||
} | ||
|
||
return sceneCamera; | ||
} | ||
} | ||
} | ||
|
||
#endif |
11 changes: 11 additions & 0 deletions
11
crest/Assets/Crest/Crest/Scripts/Helpers/Editor/EditorHelpers.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters