Initial Commit
This commit is contained in:
8
CameraUtility/Editor.meta
Normal file
8
CameraUtility/Editor.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 904e122b4614a8c439caa37312b0704d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
52
CameraUtility/Editor/CameraUtility.cs
Normal file
52
CameraUtility/Editor/CameraUtility.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace DreadScripts.CameraUtility
|
||||
{
|
||||
public class CameraUtility
|
||||
{
|
||||
private const float SCENE_PIVOT_OFFSET = 1;
|
||||
|
||||
[MenuItem("DreadTools/Utility/Camera/Snap Scene To Game")]
|
||||
public static void SnapSceneViewToGame()
|
||||
{
|
||||
if (!TryGetGameCamera(out Camera gc)) return;
|
||||
|
||||
SceneView view = SceneView.lastActiveSceneView;
|
||||
if (YellowLog(view == null, "No Scene View found")) return;
|
||||
|
||||
Undo.RecordObject(view, "Snap STG");
|
||||
view.LookAtDirect(gc.transform.position, gc.transform.rotation, SCENE_PIVOT_OFFSET/2);
|
||||
view.pivot = gc.transform.position + gc.transform.forward * SCENE_PIVOT_OFFSET;
|
||||
}
|
||||
|
||||
[MenuItem("DreadTools/Utility/Camera/Snap Game To Scene")]
|
||||
public static void SnapGameViewToScene()
|
||||
{
|
||||
if (!TryGetGameCamera(out Camera gc)) return;
|
||||
if (!TryGetSceneCamera(out Camera sc)) return;
|
||||
|
||||
Undo.RecordObject(gc.transform, "Snap GTS");
|
||||
gc.transform.SetPositionAndRotation(sc.transform.position, sc.transform.rotation);
|
||||
}
|
||||
|
||||
private static bool TryGetGameCamera(out Camera gameCamera)
|
||||
{
|
||||
gameCamera = Camera.main ?? Object.FindObjectOfType<Camera>();
|
||||
return !YellowLog(!gameCamera, "No Camera found in scene");
|
||||
}
|
||||
private static bool TryGetSceneCamera(out Camera sceneCamera)
|
||||
{
|
||||
sceneCamera = SceneView.lastActiveSceneView?.camera;
|
||||
return !YellowLog(!sceneCamera, "No Scene View found");
|
||||
}
|
||||
|
||||
private static bool YellowLog(bool condition, string msg)
|
||||
{
|
||||
if (condition) Debug.LogWarning($"<color=yellow>[CameraUtility] {msg}</color>");
|
||||
return condition;
|
||||
}
|
||||
}
|
||||
}
|
11
CameraUtility/Editor/CameraUtility.cs.meta
Normal file
11
CameraUtility/Editor/CameraUtility.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e230c2bf340461c46939efc284f6bf22
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
@@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "com.dreadscripts.camerautility.Editor",
|
||||
"references": [],
|
||||
"includePlatforms": [
|
||||
"Editor"
|
||||
],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": [],
|
||||
"versionDefines": [],
|
||||
"noEngineReferences": false
|
||||
}
|
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: acb80353a76f6c0488836f3e26ef1785
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
21
CameraUtility/LICENSE
Normal file
21
CameraUtility/LICENSE
Normal file
@@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2024 Dreadrith
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
7
CameraUtility/LICENSE.meta
Normal file
7
CameraUtility/LICENSE.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c6d418ac183680543906fe0d17a02a3a
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
16
CameraUtility/README.md
Normal file
16
CameraUtility/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Camera Utility
|
||||
|
||||
### [Download From Here](https://vpm.dreadscripts.com/)
|
||||
|
||||

|
||||
|
||||
## Features
|
||||
- Snap the Scene view to the position and rotation of the Game view camera or vice versa.
|
||||
|
||||
## How to Use
|
||||
1. Open the Unity Editor.
|
||||
2. Navigate to `DreadTools > Utility > Camera` in the top menu.
|
||||
3. Choose either "Snap Scene To Game" or "Snap Game To Scene" to synchronize views accordingly.
|
||||
|
||||
### Thank You
|
||||
If you enjoy Camera Utility, please consider [supporting me ♡](https://ko-fi.com/Dreadrith)!
|
7
CameraUtility/README.md.meta
Normal file
7
CameraUtility/README.md.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: df3ef724ecd912644ab09c0dd1490ca1
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
17
CameraUtility/package.json
Normal file
17
CameraUtility/package.json
Normal file
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "com.dreadscripts.camerautility",
|
||||
"displayName": "DreadScripts - CameraUtility",
|
||||
"version": "1.0.1",
|
||||
"description": "Simple menu item to snap Game View to Scene View or vice versa.",
|
||||
"gitDependencies": {},
|
||||
"vpmDependencies": {},
|
||||
"author": {
|
||||
"name": "Dreadrith",
|
||||
"email": "dreadscripts@gmail.com",
|
||||
"url": "https://www.dreadrith.com"
|
||||
},
|
||||
"legacyFolders": {},
|
||||
"legacyFiles": {},
|
||||
"type": "tool",
|
||||
"unity": "2019.4"
|
||||
}
|
7
CameraUtility/package.json.meta
Normal file
7
CameraUtility/package.json.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c08baa384bf219b4494368267dea3617
|
||||
TextScriptImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Reference in New Issue
Block a user