Initial Commit

This commit is contained in:
jellejurre
2025-07-19 01:03:02 +02:00
commit e7904e3140
304 changed files with 22521 additions and 0 deletions

View 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;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e230c2bf340461c46939efc284f6bf22
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,15 @@
{
"name": "com.dreadscripts.camerautility.Editor",
"references": [],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: acb80353a76f6c0488836f3e26ef1785
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant: