阶段性完成

This commit is contained in:
SoulliesOfficial
2025-12-08 05:27:53 -05:00
parent ef7b479712
commit f7af60351b
8770 changed files with 15637030 additions and 208354 deletions

View File

@@ -0,0 +1,151 @@
using UnityEngine;
#if UNITY_EDITOR
using UnityEditorInternal;
using UnityEditor;
/// <summary>
/// FM: Editor class component to be inherited, class is containing handly methods for handles in scene view
/// </summary>
public static class FEditor_TransformHandles
{
/// <summary>
/// [To be executed in OnSceneGUI()]
/// Drawing sphere handle in scene view with controll ability
/// </summary>
public static Vector3 DrawAndSetPositionForHandle(Vector3 position, Transform rootReference)
{
EditorGUI.BeginChangeCheck();
Handles.color = Color.green;
Quaternion rotation = (UnityEditor.Tools.pivotRotation != UnityEditor.PivotRotation.Local) ? Quaternion.identity : rootReference.rotation;
float size = HandleUtility.GetHandleSize(position) * 0.125f;
Handles.SphereHandleCap(0, position, rotation, size, UnityEngine.EventType.Repaint);
Vector3 pos = Handles.PositionHandle(position, rotation);
return pos;
}
/// <summary>
/// [To be executed in OnSceneGUI()]
/// Drawing sphere handle in scene view without option to controll it but clickable
/// Returns true if mouse clicked on handle
/// </summary>
public static bool DrawSphereHandle(Vector3 position, string text = "")
{
bool clicked = false;
if (Event.current.button != 1)
{
Handles.color = Color.white;
float size = HandleUtility.GetHandleSize(position) * 0.2f;
if (Handles.Button(position, Quaternion.identity, size, size, Handles.SphereHandleCap))
{
clicked = true;
InternalEditorUtility.RepaintAllViews();
}
Handles.BeginGUI();
Vector2 labelSize = new Vector2(EditorGUIUtility.singleLineHeight * 2, EditorGUIUtility.singleLineHeight);
Vector2 labelPos = HandleUtility.WorldToGUIPoint(position);
labelPos.y -= labelSize.y / 2;
labelPos.x -= labelSize.x / 2;
GUILayout.BeginArea(new Rect(labelPos, labelSize));
GUIStyle style = new GUIStyle();
style.normal.textColor = Color.black;
style.alignment = UnityEngine.TextAnchor.MiddleCenter;
GUILayout.Label(new GUIContent(text), style);
GUILayout.EndArea();
Handles.EndGUI();
}
return clicked;
}
public static Quaternion RotationHandle(Quaternion rotation, Vector3 position, float size = 1f, bool worldScale = false)
{
float handleSize = size;
if (worldScale) handleSize = HandleUtility.GetHandleSize(position) * size;
Color color = Handles.color;
Handles.color = Handles.xAxisColor;
rotation = Handles.Disc(rotation, position, rotation * Vector3.right, handleSize, true, 1f);
Handles.color = Handles.yAxisColor;
rotation = Handles.Disc(rotation, position, rotation * Vector3.up, handleSize, true, 1f);
Handles.color = Handles.zAxisColor;
rotation = Handles.Disc(rotation, position, rotation * Vector3.forward, handleSize, true, 1f);
Handles.color = Handles.centerColor;
rotation = Handles.Disc(rotation, position, Camera.current.transform.forward, handleSize * 1.1f, false, 0f);
rotation = Handles.FreeRotateHandle(rotation, position, handleSize);
Handles.color = color;
return rotation;
}
public static Vector3 ScaleHandle(Vector3 scale, Vector3 position, Quaternion rotation, float size, bool scaleAll = false, bool worldScale = false)
{
float handleSize = size;
if (worldScale) handleSize = HandleUtility.GetHandleSize(position) * size;
if (!scaleAll)
{
Handles.color = Handles.xAxisColor;
scale.x = Handles.ScaleSlider(scale.x, position, rotation * Vector3.right, rotation, handleSize, 0.001f);
Handles.color = Handles.yAxisColor;
scale.y = Handles.ScaleSlider(scale.y, position, rotation * Vector3.up, rotation, handleSize, 0.001f);
Handles.color = Handles.zAxisColor;
scale.z = Handles.ScaleSlider(scale.z, position, rotation * Vector3.forward, rotation, handleSize, 0.001f);
}
Handles.color = Handles.centerColor;
EditorGUI.BeginChangeCheck();
float num1 = Handles.ScaleValueHandle(scale.x, position, rotation, handleSize, Handles.CubeHandleCap, 0.001f);
if (EditorGUI.EndChangeCheck())
{
float num2 = num1 / scale.x;
scale.x = num1;
scale.y *= num2;
scale.z *= num2;
}
return scale;
}
public static Vector3 PositionHandle(Vector3 position, Quaternion rotation, float size = 1f, bool worldScale = false, bool freeHandle = true, bool colorize = true)
{
float handleSize = size;
if (worldScale) handleSize = HandleUtility.GetHandleSize(position) * size;
Color color = Handles.color;
if (colorize) Handles.color = Handles.xAxisColor;
position = Handles.Slider(position, rotation * Vector3.right, handleSize, Handles.ArrowHandleCap, 0.001f);
if (colorize) Handles.color = Handles.yAxisColor;
position = Handles.Slider(position, rotation * Vector3.up, handleSize, Handles.ArrowHandleCap, 0.001f);
if (colorize) Handles.color = Handles.zAxisColor;
position = Handles.Slider(position, rotation * Vector3.forward, handleSize, Handles.ArrowHandleCap, 0.001f);
if (freeHandle)
{
Handles.color = Handles.centerColor;
position = Handles.FreeMoveHandle(position, handleSize * 0.15f, Vector3.one * 0.001f, Handles.RectangleHandleCap);
}
Handles.color = color;
return position;
}
}
#endif

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: be7be99b69bf5124fa755f8839023d0a
timeCreated: 1554133585
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,63 @@
#if UNITY_EDITOR
using UnityEditor;
#endif
using UnityEngine;
/* Code made by LaneFox from Unity Community Forum */
#if UNITY_EDITOR
[InitializeOnLoad]
#endif
public class FHierarchyIcons
{
static FHierarchyIcons()
{
#if UNITY_EDITOR
EditorApplication.hierarchyWindowItemOnGUI += EvaluateIcons;
#endif
}
private static void EvaluateIcons(int instanceId, Rect selectionRect)
{
#if UNITY_EDITOR
GameObject go = EditorUtility.InstanceIDToObject(instanceId) as GameObject;
if (go == null) return;
IFHierarchyIcon slotCon = go.GetComponent<IFHierarchyIcon>();
if (slotCon != null) DrawIcon(slotCon.EditorIconPath, selectionRect);
#endif
}
private static void DrawIcon(string texName, Rect rect)
{
#if UNITY_EDITOR
if (string.IsNullOrEmpty(texName)) return;
Rect r = new Rect(rect.x + rect.width - 16f, rect.y, 16f, 16f);
GUI.DrawTexture(r, GetTex(texName));
#endif
}
private static Texture2D GetTex(string name)
{
#if UNITY_EDITOR
return (Texture2D)Resources.Load(name);
#else
return null;
#endif
}
}
public interface IFHierarchyIcon
{
string EditorIconPath { get; }
}
/*
{...}
public class ItemUiSlot : MonoBehaviour, IDropHandler, FIHierarchyIcon
{
public string EditorIconPath { get { return "LogoGrey"; } }
{...}
*/

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 43cefd6bb03808e44a8820aaee19821a
timeCreated: 1553875458
licenseType: Store
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,55 @@
#if UNITY_EDITOR
using System.Reflection;
using UnityEditor;
#endif
using UnityEngine;
public static class FSceneIcons
{
public static void SetGizmoIconEnabled(MonoBehaviour beh, bool on)
{
if (beh == null) return;
SetGizmoIconEnabled(beh.GetType(), on);
}
public static void SetGizmoIconEnabled(System.Type type, bool on)
{
#if UNITY_EDITOR
if (Application.isPlaying) return;
//#if UNITY_2022_1_OR_NEWER
// On newer unity versions it stopped working
// giving warning: "Warning: Annotation not found!"
// and can't find any info in docs, how to make it work again
//#else
// giving warning: "Warning: Annotation not found!"
// sometimes it works, sometimes not ¯\_(ツ)_/¯ lets see how bad it goes now
try
{
var etype = typeof(Editor);
var annotation = etype.Assembly.GetType("UnityEditor.Annotation");
var scriptClass = annotation.GetField("scriptClass");
var classID = annotation.GetField("classID");
var annotation_util = etype.Assembly.GetType("UnityEditor.AnnotationUtility");
var getAnnotations = annotation_util.GetMethod("GetAnnotations", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
var setIconEnabled = annotation_util.GetMethod("SetIconEnabled", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
var annotations = getAnnotations.Invoke(null, null) as System.Array;
foreach (var a in annotations)
{
int cid = (int)classID.GetValue(a);
string cls = (string)scriptClass.GetValue(a);
setIconEnabled.Invoke(null, new object[] { cid, cls, on ? 1 : 0 });
}
}
catch (System.Exception)
{
}
#endif
}
}

View File

@@ -0,0 +1,19 @@
fileFormatVersion: 2
guid: abb9419990ed1be408d510d2f163b305
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
AssetOrigin:
serializedVersion: 1
productId: 154245
packageName: Legs Animator
packageVersion: 1.0.1
assetPath: Assets/FImpossible Creations/Shared Tools/Editor Tools/Inspector And
Scene Tools/FSceneIcons.cs
uploadId: 631264