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
public static class Inspector | |
{ | |
public static void InspectorRename(bool inspector = false) | |
{ | |
EditorWindow windowToBeLocked = EditorWindow.mouseOverWindow; | |
if (windowToBeLocked.GetType().ToString().Equals("UnityEditor.InspectorWindow")) | |
{ | |
if (inspector) | |
{ | |
Texture tex = windowToBeLocked.titleContent.image; |
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
[MenuItem("Tools/Inspector rename &r")] | |
public static void InspectorSwitchName() | |
{ | |
EditorWindow windowToBeLocked = EditorWindow.mouseOverWindow; | |
if (windowToBeLocked.GetType().ToString().Equals("UnityEditor.InspectorWindow")) | |
{ | |
if (windowToBeLocked.title != "Inspector") | |
{ | |
Texture tex = windowToBeLocked.titleContent.image; | |
windowToBeLocked.title = "Inspector"; |
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
public static class BinaryFormatterWrapper | |
{ | |
private static BinaryFormatter BinaryFormatter => binaryFormatter ?? (binaryFormatter = new BinaryFormatter()); | |
private static BinaryFormatter binaryFormatter; | |
public static byte[] SerializeToByteArray(this object obj) | |
{ | |
using (MemoryStream memoryStream = new MemoryStream()) | |
{ | |
BinaryFormatter.Serialize(memoryStream, obj); |
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
using UnityEngine; | |
public static class VectorExtensions | |
{ | |
// 2 component combinations | |
public static Vector4 XY__(this Vector2 aVec, float aZ = 0, float aW = 0) { return new Vector4(aVec.x, aVec.y, aZ, aW); } | |
public static Vector4 XY__(this Vector3 aVec, float aZ = 0, float aW = 0) { return new Vector4(aVec.x, aVec.y, aZ, aW); } | |
public static Vector4 XY__(this Vector4 aVec, float aZ = 0, float aW = 0) { return new Vector4(aVec.x, aVec.y, aZ, aW); } | |
public static Vector4 X_Y_(this Vector2 aVec, float aY = 0, float aW = 0) { return new Vector4(aVec.x, aY, aVec.y, aW); } |
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
public static ScriptableObject DrawColoredList(ScriptableObject scriptableObject, int i, ScriptableObject selected) | |
{ | |
if (scriptableObject == selected) | |
GUILayout.BeginHorizontal(EditorStyle.GetSelectedStyle()); | |
else if (i % 2 == 0) | |
GUILayout.BeginHorizontal(EditorStyle.GetGreyedOutStyle()); | |
else | |
GUILayout.BeginHorizontal(); | |
if (GUILayout.Button(scriptableObject.name, EditorStyle.ListElementStyle)) |
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
public static IEnumerable<Type> GetTypesWith<TAttribute>(bool inherit) | |
where TAttribute : Attribute | |
{ | |
return AppDomain.CurrentDomain.GetAssemblies() | |
.SelectMany(a => a.GetTypes()) | |
.Where(t => t.IsDefined(typeof(TAttribute), inherit)); | |
} |
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
public static List<T> FindAssetsByType<T>() where T : Object | |
{ | |
List<T> assets = new List<T>(); | |
string[] guids = AssetDatabase.FindAssets(string.Format("t:{0}", typeof(T))); | |
for( int i = 0; i < guids.Length; i++ ) | |
{ | |
string assetPath = AssetDatabase.GUIDToAssetPath( guids[i] ); | |
T asset = AssetDatabase.LoadAssetAtPath<T>( assetPath ); | |
if( asset != null ) | |
{ |
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
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEditor; | |
using UnityEngine; | |
public static class EditorWindowExtensions | |
{ | |
public static string Save(this EditorWindow window) | |
{ | |
var data = JsonUtility.ToJson(window, false); |
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
using System; | |
using System.Reflection; | |
using UnityEditor; | |
namespace Plugins.Gists.Editor | |
{ | |
public static class InspectorLockToggle | |
{ | |
[MenuItem("Tools/Toggle Lock &q")] | |
static void ToggleWindowLock() // Inspector must be inspecting something to be locked |
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
Vector3 diff = lookAt3dPosition - transform.position; | |
diff.Normalize(); | |
float rot_z = Mathf.Atan2(diff.y, diff.x) * Mathf.Rad2Deg; | |
transform.rotation = Quaternion.Euler(0f, 0f, rot_z - 90); |
NewerOlder