Linux migration.
This commit is contained in:
@ -1,38 +1,38 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[CustomEditor(typeof(EventManager), true)]
|
||||
public class EventManagerEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var eventManager = (EventManager)target;
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Update");
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(EventManager.UpdateLength.ToString());
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("FixedUpdate");
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(EventManager.FixedUpdateLength.ToString());
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("LateUpdate");
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(EventManager.LateUpdateLength.ToString());
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[CustomEditor(typeof(EventManager), true)]
|
||||
public class EventManagerEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
var eventManager = (EventManager)target;
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("Update");
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(EventManager.UpdateLength.ToString());
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("FixedUpdate");
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(EventManager.FixedUpdateLength.ToString());
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
GUILayout.BeginHorizontal();
|
||||
GUILayout.Label("LateUpdate");
|
||||
if (Application.isPlaying)
|
||||
{
|
||||
GUILayout.FlexibleSpace();
|
||||
GUILayout.Label(EventManager.LateUpdateLength.ToString());
|
||||
}
|
||||
GUILayout.EndHorizontal();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,51 +1,51 @@
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
public class PackgeUpdater
|
||||
{
|
||||
private static string ManifestPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var projectPath = Directory.GetParent(Application.dataPath).FullName;
|
||||
var manifestPath = Path.Combine(projectPath, "Packages", "manifest.json");
|
||||
return manifestPath;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetIdentifier(string input, char charFrom, char charTo)
|
||||
{
|
||||
var first = input.IndexOf(charFrom);
|
||||
var second = input.IndexOf(charTo, first + 1);
|
||||
var posFrom = input.IndexOf(charFrom, second + 1);
|
||||
if (posFrom != -1) //if found char
|
||||
{
|
||||
var posTo = input.IndexOf(charTo, posFrom + 1);
|
||||
if (posTo != -1) //if found char
|
||||
{
|
||||
return input.Substring(posFrom + 1, posTo - posFrom - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Update Git Packages", false, 1000)]
|
||||
private static void UpdateGitPackages()
|
||||
{
|
||||
var lines = File.ReadAllLines(ManifestPath);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
if (line.Contains("git"))
|
||||
{
|
||||
var identifier = GetIdentifier(line, '"', '"');
|
||||
Debug.Log("Checking for updates " + identifier);
|
||||
UnityEditor.PackageManager.Client.Add(identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using System.IO;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
public class PackgeUpdater
|
||||
{
|
||||
private static string ManifestPath
|
||||
{
|
||||
get
|
||||
{
|
||||
var projectPath = Directory.GetParent(Application.dataPath).FullName;
|
||||
var manifestPath = Path.Combine(projectPath, "Packages", "manifest.json");
|
||||
return manifestPath;
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetIdentifier(string input, char charFrom, char charTo)
|
||||
{
|
||||
var first = input.IndexOf(charFrom);
|
||||
var second = input.IndexOf(charTo, first + 1);
|
||||
var posFrom = input.IndexOf(charFrom, second + 1);
|
||||
if (posFrom != -1) //if found char
|
||||
{
|
||||
var posTo = input.IndexOf(charTo, posFrom + 1);
|
||||
if (posTo != -1) //if found char
|
||||
{
|
||||
return input.Substring(posFrom + 1, posTo - posFrom - 1);
|
||||
}
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
[MenuItem("Assets/Update Git Packages", false, 1000)]
|
||||
private static void UpdateGitPackages()
|
||||
{
|
||||
var lines = File.ReadAllLines(ManifestPath);
|
||||
foreach (var line in lines)
|
||||
{
|
||||
if (line.Contains("git"))
|
||||
{
|
||||
var identifier = GetIdentifier(line, '"', '"');
|
||||
Debug.Log("Checking for updates " + identifier);
|
||||
UnityEditor.PackageManager.Client.Add(identifier);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,16 +1,16 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(ReadOnlyFieldAttribute))]
|
||||
public class ReadOnlyFieldDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(ReadOnlyFieldAttribute))]
|
||||
public class ReadOnlyFieldDrawer : PropertyDrawer
|
||||
{
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
GUI.enabled = false;
|
||||
EditorGUI.PropertyField(position, property, label, true);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,168 +1,168 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
public class ReflectionProbeVolumeEditor : MonoBehaviour
|
||||
{
|
||||
[CustomEditor(typeof(ReflectionProbeVolume), true)]
|
||||
public class EventManagerEditor : Editor
|
||||
{
|
||||
private SerializedProperty resolution;
|
||||
private SerializedProperty offset;
|
||||
private SerializedProperty threshold;
|
||||
private SerializedProperty blendDistance;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
resolution = serializedObject.FindProperty("resolution");
|
||||
offset = serializedObject.FindProperty("offset");
|
||||
threshold = serializedObject.FindProperty("threshold");
|
||||
blendDistance = serializedObject.FindProperty("blendDistance");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(resolution);
|
||||
EditorGUILayout.PropertyField(offset);
|
||||
EditorGUILayout.PropertyField(threshold);
|
||||
EditorGUILayout.PropertyField(blendDistance);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Place"))
|
||||
{
|
||||
Place();
|
||||
}
|
||||
}
|
||||
|
||||
private void Place()
|
||||
{
|
||||
var voxelSize = resolution.intValue;
|
||||
var offset = this.offset.floatValue;
|
||||
var threshold = this.threshold.floatValue;
|
||||
var blendDistance = this.blendDistance.floatValue;
|
||||
ReflectionProbeVolume reflectionProbeVolume = (ReflectionProbeVolume)target;
|
||||
var transform = reflectionProbeVolume.transform;
|
||||
//Gizmos.DrawWireCube(transform.position, transform.localScale);
|
||||
var startPos = transform.position + transform.right * transform.localScale.x / 2 + transform.up * transform.localScale.y / 2 + transform.forward * transform.localScale.z / 2;
|
||||
var xVar = transform.localScale.x / voxelSize / 2f;
|
||||
var zVar = transform.localScale.z / voxelSize / 2f;
|
||||
var data = new Vector3[voxelSize, voxelSize];
|
||||
//Gizmos.color = Color.blue;
|
||||
for (int x = 0; x < voxelSize; x++)
|
||||
{
|
||||
for (int z = 0; z < voxelSize; z++)
|
||||
{
|
||||
var rayPos = startPos - transform.right * xVar - transform.forward * zVar;
|
||||
if (Physics.Raycast(rayPos, Vector2.down, out RaycastHit hit))
|
||||
{
|
||||
var point = hit.point + Vector3.up * offset;
|
||||
data[x, z] = point;
|
||||
}
|
||||
zVar += transform.localScale.z / voxelSize;
|
||||
}
|
||||
xVar += transform.localScale.x / voxelSize;
|
||||
zVar = transform.localScale.z / voxelSize / 2f;
|
||||
}
|
||||
|
||||
CheckSquare(data, 5, voxelSize, threshold, blendDistance, transform);
|
||||
CheckSquare(data, 4, voxelSize, threshold, blendDistance, transform);
|
||||
CheckSquare(data, 3, voxelSize, threshold, blendDistance, transform);
|
||||
CheckSquare(data, 2, voxelSize, threshold, blendDistance, transform);
|
||||
|
||||
for (int x = 0; x < voxelSize; x++)
|
||||
{
|
||||
for (int z = 0; z < voxelSize; z++)
|
||||
{
|
||||
if (data[x, z].x != float.PositiveInfinity)
|
||||
{
|
||||
var go = new GameObject("Reflection Probe Size: 1");
|
||||
go.transform.SetParent(transform);
|
||||
go.transform.position = data[x, z];
|
||||
var reflectionProbe = go.AddComponent(typeof(ReflectionProbe)) as ReflectionProbe;
|
||||
reflectionProbe.resolution = 16;
|
||||
reflectionProbe.center = new Vector3(0f, transform.position.y - data[x, z].y, 0f);
|
||||
reflectionProbe.size = new Vector3(transform.localScale.x / voxelSize + blendDistance, transform.localScale.y, transform.localScale.z / voxelSize + blendDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSquare(Vector3[,] data, int size, int voxelSize, float threshold, float blendDistance, Transform transform)
|
||||
{
|
||||
for (int x = 0; x < voxelSize; x++)
|
||||
{
|
||||
for (int z = 0; z < voxelSize; z++)
|
||||
{
|
||||
if (x + size <= voxelSize && z + size <= voxelSize)
|
||||
{
|
||||
bool valid = true;
|
||||
var point = Vector3.zero;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int k = 0; k < size; k++)
|
||||
{
|
||||
var pos = data[x + i, z + k];
|
||||
if (pos != Vector3.positiveInfinity)
|
||||
{
|
||||
if (Compare(data[x, z].y, pos.y, threshold))
|
||||
{
|
||||
point += pos;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
point /= size * size;
|
||||
|
||||
var go = new GameObject("Reflection Probe Size: " + size);
|
||||
go.transform.SetParent(transform);
|
||||
go.transform.position = point;
|
||||
var reflectionProbe = go.AddComponent(typeof(ReflectionProbe)) as ReflectionProbe;
|
||||
if (size == 2)
|
||||
{
|
||||
reflectionProbe.resolution = 16;
|
||||
}
|
||||
else if (size == 3)
|
||||
{
|
||||
reflectionProbe.resolution = 32;
|
||||
}
|
||||
else if (size == 4)
|
||||
{
|
||||
reflectionProbe.resolution = 32;
|
||||
}
|
||||
else if (size == 5)
|
||||
{
|
||||
reflectionProbe.resolution = 64;
|
||||
}
|
||||
|
||||
reflectionProbe.center = new Vector3(0f, transform.position.y - point.y, 0f);
|
||||
reflectionProbe.size = new Vector3(transform.localScale.x / voxelSize * size + blendDistance, transform.localScale.y, transform.localScale.z / voxelSize * size + blendDistance);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int k = 0; k < size; k++)
|
||||
{
|
||||
data[x + i, z + k] = Vector3.positiveInfinity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool Compare(float arg0, float arg1, float threshold)
|
||||
{
|
||||
return Mathf.Abs(arg0 - arg1) < threshold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
public class ReflectionProbeVolumeEditor : MonoBehaviour
|
||||
{
|
||||
[CustomEditor(typeof(ReflectionProbeVolume), true)]
|
||||
public class EventManagerEditor : Editor
|
||||
{
|
||||
private SerializedProperty resolution;
|
||||
private SerializedProperty offset;
|
||||
private SerializedProperty threshold;
|
||||
private SerializedProperty blendDistance;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
resolution = serializedObject.FindProperty("resolution");
|
||||
offset = serializedObject.FindProperty("offset");
|
||||
threshold = serializedObject.FindProperty("threshold");
|
||||
blendDistance = serializedObject.FindProperty("blendDistance");
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
EditorGUILayout.PropertyField(resolution);
|
||||
EditorGUILayout.PropertyField(offset);
|
||||
EditorGUILayout.PropertyField(threshold);
|
||||
EditorGUILayout.PropertyField(blendDistance);
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
EditorGUILayout.Space();
|
||||
if (GUILayout.Button("Place"))
|
||||
{
|
||||
Place();
|
||||
}
|
||||
}
|
||||
|
||||
private void Place()
|
||||
{
|
||||
var voxelSize = resolution.intValue;
|
||||
var offset = this.offset.floatValue;
|
||||
var threshold = this.threshold.floatValue;
|
||||
var blendDistance = this.blendDistance.floatValue;
|
||||
ReflectionProbeVolume reflectionProbeVolume = (ReflectionProbeVolume)target;
|
||||
var transform = reflectionProbeVolume.transform;
|
||||
//Gizmos.DrawWireCube(transform.position, transform.localScale);
|
||||
var startPos = transform.position + transform.right * transform.localScale.x / 2 + transform.up * transform.localScale.y / 2 + transform.forward * transform.localScale.z / 2;
|
||||
var xVar = transform.localScale.x / voxelSize / 2f;
|
||||
var zVar = transform.localScale.z / voxelSize / 2f;
|
||||
var data = new Vector3[voxelSize, voxelSize];
|
||||
//Gizmos.color = Color.blue;
|
||||
for (int x = 0; x < voxelSize; x++)
|
||||
{
|
||||
for (int z = 0; z < voxelSize; z++)
|
||||
{
|
||||
var rayPos = startPos - transform.right * xVar - transform.forward * zVar;
|
||||
if (Physics.Raycast(rayPos, Vector2.down, out RaycastHit hit))
|
||||
{
|
||||
var point = hit.point + Vector3.up * offset;
|
||||
data[x, z] = point;
|
||||
}
|
||||
zVar += transform.localScale.z / voxelSize;
|
||||
}
|
||||
xVar += transform.localScale.x / voxelSize;
|
||||
zVar = transform.localScale.z / voxelSize / 2f;
|
||||
}
|
||||
|
||||
CheckSquare(data, 5, voxelSize, threshold, blendDistance, transform);
|
||||
CheckSquare(data, 4, voxelSize, threshold, blendDistance, transform);
|
||||
CheckSquare(data, 3, voxelSize, threshold, blendDistance, transform);
|
||||
CheckSquare(data, 2, voxelSize, threshold, blendDistance, transform);
|
||||
|
||||
for (int x = 0; x < voxelSize; x++)
|
||||
{
|
||||
for (int z = 0; z < voxelSize; z++)
|
||||
{
|
||||
if (data[x, z].x != float.PositiveInfinity)
|
||||
{
|
||||
var go = new GameObject("Reflection Probe Size: 1");
|
||||
go.transform.SetParent(transform);
|
||||
go.transform.position = data[x, z];
|
||||
var reflectionProbe = go.AddComponent(typeof(ReflectionProbe)) as ReflectionProbe;
|
||||
reflectionProbe.resolution = 16;
|
||||
reflectionProbe.center = new Vector3(0f, transform.position.y - data[x, z].y, 0f);
|
||||
reflectionProbe.size = new Vector3(transform.localScale.x / voxelSize + blendDistance, transform.localScale.y, transform.localScale.z / voxelSize + blendDistance);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckSquare(Vector3[,] data, int size, int voxelSize, float threshold, float blendDistance, Transform transform)
|
||||
{
|
||||
for (int x = 0; x < voxelSize; x++)
|
||||
{
|
||||
for (int z = 0; z < voxelSize; z++)
|
||||
{
|
||||
if (x + size <= voxelSize && z + size <= voxelSize)
|
||||
{
|
||||
bool valid = true;
|
||||
var point = Vector3.zero;
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int k = 0; k < size; k++)
|
||||
{
|
||||
var pos = data[x + i, z + k];
|
||||
if (pos != Vector3.positiveInfinity)
|
||||
{
|
||||
if (Compare(data[x, z].y, pos.y, threshold))
|
||||
{
|
||||
point += pos;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
valid = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (valid)
|
||||
{
|
||||
point /= size * size;
|
||||
|
||||
var go = new GameObject("Reflection Probe Size: " + size);
|
||||
go.transform.SetParent(transform);
|
||||
go.transform.position = point;
|
||||
var reflectionProbe = go.AddComponent(typeof(ReflectionProbe)) as ReflectionProbe;
|
||||
if (size == 2)
|
||||
{
|
||||
reflectionProbe.resolution = 16;
|
||||
}
|
||||
else if (size == 3)
|
||||
{
|
||||
reflectionProbe.resolution = 32;
|
||||
}
|
||||
else if (size == 4)
|
||||
{
|
||||
reflectionProbe.resolution = 32;
|
||||
}
|
||||
else if (size == 5)
|
||||
{
|
||||
reflectionProbe.resolution = 64;
|
||||
}
|
||||
|
||||
reflectionProbe.center = new Vector3(0f, transform.position.y - point.y, 0f);
|
||||
reflectionProbe.size = new Vector3(transform.localScale.x / voxelSize * size + blendDistance, transform.localScale.y, transform.localScale.z / voxelSize * size + blendDistance);
|
||||
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
for (int k = 0; k < size; k++)
|
||||
{
|
||||
data[x + i, z + k] = Vector3.positiveInfinity;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private bool Compare(float arg0, float arg1, float threshold)
|
||||
{
|
||||
return Mathf.Abs(arg0 - arg1) < threshold;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,81 +1,81 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public static class SceneViewRotation
|
||||
{
|
||||
private static bool toggleDir;
|
||||
|
||||
static SceneViewRotation()
|
||||
{
|
||||
SceneView.duringSceneGui += OnSceneGUI;
|
||||
}
|
||||
|
||||
private static void OnSceneGUI(SceneView sceneView)
|
||||
{
|
||||
if (sceneView.isRotationLocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Event e = Event.current;
|
||||
switch (e.type)
|
||||
{
|
||||
case EventType.KeyDown:
|
||||
if (e.keyCode == KeyCode.Keypad1)
|
||||
{
|
||||
sceneView.rotation = Quaternion.LookRotation(toggleDir ? Vector3.forward : Vector3.back);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad2)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x - 15f, angles.y, angles.z);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad3)
|
||||
{
|
||||
sceneView.rotation = Quaternion.LookRotation(toggleDir ? Vector3.left : Vector3.right);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad4)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x, angles.y + 15f, angles.z);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad5)
|
||||
{
|
||||
sceneView.orthographic = !sceneView.orthographic;
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad6)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x, angles.y - 15f, angles.z);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad7)
|
||||
{
|
||||
sceneView.rotation = new Quaternion(0f, toggleDir ? -.7f : .7f, -.7f, 0f);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad8)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x + 15f, angles.y, angles.z);
|
||||
}
|
||||
//else if (e.keyCode == KeyCode.Keypad9)
|
||||
//{
|
||||
// //sceneView.rotation = Quaternion.LookRotation(-sceneView.camera.transform.forward);
|
||||
// sceneView.rotation = Quaternion.Inverse(sceneView.rotation);
|
||||
//}
|
||||
else if (e.keyCode == KeyCode.LeftControl)
|
||||
{
|
||||
toggleDir = true;
|
||||
}
|
||||
break;
|
||||
case EventType.KeyUp:
|
||||
if (e.keyCode == KeyCode.LeftControl)
|
||||
{
|
||||
toggleDir = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace Utils
|
||||
{
|
||||
[InitializeOnLoad]
|
||||
public static class SceneViewRotation
|
||||
{
|
||||
private static bool toggleDir;
|
||||
|
||||
static SceneViewRotation()
|
||||
{
|
||||
SceneView.duringSceneGui += OnSceneGUI;
|
||||
}
|
||||
|
||||
private static void OnSceneGUI(SceneView sceneView)
|
||||
{
|
||||
if (sceneView.isRotationLocked)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Event e = Event.current;
|
||||
switch (e.type)
|
||||
{
|
||||
case EventType.KeyDown:
|
||||
if (e.keyCode == KeyCode.Keypad1)
|
||||
{
|
||||
sceneView.rotation = Quaternion.LookRotation(toggleDir ? Vector3.forward : Vector3.back);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad2)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x - 15f, angles.y, angles.z);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad3)
|
||||
{
|
||||
sceneView.rotation = Quaternion.LookRotation(toggleDir ? Vector3.left : Vector3.right);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad4)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x, angles.y + 15f, angles.z);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad5)
|
||||
{
|
||||
sceneView.orthographic = !sceneView.orthographic;
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad6)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x, angles.y - 15f, angles.z);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad7)
|
||||
{
|
||||
sceneView.rotation = new Quaternion(0f, toggleDir ? -.7f : .7f, -.7f, 0f);
|
||||
}
|
||||
else if (e.keyCode == KeyCode.Keypad8)
|
||||
{
|
||||
var angles = sceneView.rotation.eulerAngles;
|
||||
sceneView.rotation = Quaternion.Euler(angles.x + 15f, angles.y, angles.z);
|
||||
}
|
||||
//else if (e.keyCode == KeyCode.Keypad9)
|
||||
//{
|
||||
// //sceneView.rotation = Quaternion.LookRotation(-sceneView.camera.transform.forward);
|
||||
// sceneView.rotation = Quaternion.Inverse(sceneView.rotation);
|
||||
//}
|
||||
else if (e.keyCode == KeyCode.LeftControl)
|
||||
{
|
||||
toggleDir = true;
|
||||
}
|
||||
break;
|
||||
case EventType.KeyUp:
|
||||
if (e.keyCode == KeyCode.LeftControl)
|
||||
{
|
||||
toggleDir = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user