导入leg插件,完成腿部动画

This commit is contained in:
2025-09-24 15:12:17 +08:00
parent 5087ff1cfe
commit 090e86c0ee
1087 changed files with 417484 additions and 30288 deletions

View File

@@ -0,0 +1,227 @@
#if UNITY_EDITOR
using System.Diagnostics;
using FIMSpace.FEditor;
using UnityEditor;
using UnityEngine;
#endif
namespace FIMSpace
{
/// <summary> Simple class for performance measurement.
/// After making build, all body of this class disappears to make it weightless.
/// It's not inside editor directory to give possibility to use it in main assembly. </summary>
public class FDebug_PerformanceTest
{
#if UNITY_EDITOR
Stopwatch watch = null;
GameObject parent;
long lastTicks = 0;
long lastMS = 0;
long dispTicks = 0;
double dispMS = 0;
public long LastMinTicks { get; private set; }
public long LastMaxTicks { get; private set; }
#endif
public FDebug_PerformanceTest()
{
#if UNITY_EDITOR
_foldout = false;
ResetMinMax();
#endif
}
public void ResetMinMax()
{
#if UNITY_EDITOR
LastMinTicks = long.MaxValue;
LastMaxTicks = long.MinValue;
#endif
}
public void Start(UnityEngine.GameObject owner, bool onlyIfSelected = true)
{
#if UNITY_EDITOR
//if (_foldout == false) return;
if (watch == null) watch = new Stopwatch();
parent = owner;
if (owner != null) if (onlyIfSelected) if (Selection.activeGameObject != parent) return;
watch.Reset();
watch.Start();
#endif
}
public void Pause()
{
#if UNITY_EDITOR
//if (_foldout == false) return;
if (watch.IsRunning) watch.Stop();
#endif
}
public void Continue()
{
#if UNITY_EDITOR
//if (_foldout == false) return;
if (!watch.IsRunning) watch.Start();
#endif
}
public void Finish(bool onlyIfSelected = true)
{
#if UNITY_EDITOR
//if (_foldout == false) return;
if (watch.IsRunning == false) return;
if (onlyIfSelected) if (Selection.activeGameObject != parent) return;
watch.Stop();
lastTicks = watch.ElapsedTicks;
lastMS = watch.ElapsedMilliseconds;
AddCurrentToAverage();
long avr = AverageTicks;
if (avr < LastMinTicks) LastMinTicks = avr;
if (avr > LastMaxTicks) LastMaxTicks = avr;
#endif
}
#if UNITY_EDITOR
const int AVERAGES_COUNT = 16;
int currId = 0;
long[] averageTicks = new long[AVERAGES_COUNT];
void AddCurrentToAverage()
{
averageTicks[currId] = watch.ElapsedTicks;
currId += 1;
if (currId >= AVERAGES_COUNT) currId = 0;
}
long GetAverage(long[] list)
{
long averageSum = 0;
int averageReads = 0;
long max = long.MinValue; // remembering max value
for (int i = 0; i < list.Length; i++)
{
if (list[i] <= 0) continue;
averageSum += list[i];
averageReads += 1;
if (list[i] > max) { max = list[i]; }
}
averageSum -= max; // Remove extremum value to avoid processor peak values
averageReads -= 1;
if (averageReads <= 0) return 0;
return averageSum / (long)averageReads;
}
public bool _foldout { get; private set; }
public long AverageTicks { get { return GetAverage(averageTicks); } }
public double TicksToMs(long ticks)
{
if (ticks <= 0) return 0;
return 1000.0 * (double)ticks / Stopwatch.Frequency;
}
public double AverageMS { get { return TicksToMs(AverageTicks); } }
#endif
#if UNITY_EDITOR
public void Editor_DisplayFoldoutButton(float yOffset = -20f, float xOffset = 4f)
{
var rct = GUILayoutUtility.GetLastRect();
rct.width = 12;
rct.height = 12;
rct.position = new Vector2(rct.position.x + xOffset, rct.position.y + yOffset);
Color preC = GUI.color;
GUI.color = new Color(1f, 1f, 1f, 0.7f);
if (GUI.Button(rct, FGUI_Resources.Tex_Debug, EditorStyles.label)) { _foldout = true; }
GUI.color = preC;
}
public void Editor_SwitchFoldout( bool? display = null )
{
if( display == null ) _foldout = !_foldout;
else _foldout = display.Value;
}
public void Editor_Display(string prefix = "", bool onlyPlaymode = true, bool drawAverages = true, float buttonYOffset = -20f, float buttonXOffset = 4f, float displayRate = 10f)
{
if (onlyPlaymode) if (!Application.isPlaying) return;
if (!_foldout)
{
Editor_DisplayFoldoutButton(buttonYOffset, buttonXOffset);
return;
}
Editor_DisplayAlways(prefix, false, drawAverages, displayRate);
}
float lastDisplayTime = -100f;
public bool Editor_DisplayAlways(string prefix = "", bool onlyPlaymode = true, bool drawAverages = true, float displayRate = 10f)
{
if (onlyPlaymode) if (!Application.isPlaying) return false;
#region Display Rate Implementation
float dispTime = Application.isPlaying ? Time.unscaledTime : (float)EditorApplication.timeSinceStartup;
bool updateDisp = false;
if (displayRate < 0.1f) updateDisp = true;
if (dispTime - lastDisplayTime > 1f / displayRate)
{
updateDisp = true;
lastDisplayTime = dispTime;
}
if (updateDisp)
{
if (!drawAverages)
{
dispTicks = lastTicks;
dispMS = TicksToMs(lastTicks);
}
else
{
dispTicks = AverageTicks;
dispMS = AverageMS;
}
}
#endregion
EditorGUILayout.BeginVertical(EditorStyles.helpBox);
EditorGUILayout.LabelField(prefix + "Elapsed Ticks: " + dispTicks + " " + dispMS + "ms");
EditorGUILayout.EndVertical();
var rect = GUILayoutUtility.GetLastRect();
if (GUI.Button(rect, GUIContent.none, EditorStyles.label)) { _foldout = false; }
return updateDisp;
}
#endif
}
}

View File

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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0b663972241b89542a23b642dde351c7
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,176 @@
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, bool drawX = true, bool drawY = true, bool drawZ = true, bool allowNegative = false )
{
float handleSize = size;
if( worldScale ) handleSize = HandleUtility.GetHandleSize( position ) * size;
Vector3 preScale = scale;
if( !scaleAll )
{
if( drawX )
{
Handles.color = Handles.xAxisColor;
scale.x = Handles.ScaleSlider( scale.x, position, rotation * Vector3.right, rotation, handleSize, 0.001f );
if (!allowNegative) if( Mathf.Sign( scale.x ) != Mathf.Sign( preScale.x ) ) scale.x = preScale.x * handleSize * 0.001f;
}
if( drawY )
{
Handles.color = Handles.yAxisColor;
scale.y = Handles.ScaleSlider( scale.y, position, rotation * Vector3.up, rotation, handleSize, 0.001f );
if( !allowNegative ) if( Mathf.Sign( scale.y ) != Mathf.Sign( preScale.y ) ) scale.y = preScale.y * handleSize * 0.001f;
}
if( drawZ )
{
Handles.color = Handles.zAxisColor;
scale.z = Handles.ScaleSlider( scale.z, position, rotation * Vector3.forward, rotation, handleSize, 0.001f );
if( !allowNegative ) if( Mathf.Sign( scale.z ) != Mathf.Sign( preScale.z ) ) scale.z = preScale.z * handleSize * 0.001f;
}
}
Handles.color = Handles.centerColor;
EditorGUI.BeginChangeCheck();
float num1 = Handles.ScaleValueHandle( scale.x, position, rotation, handleSize, Handles.CubeHandleCap, 0.001f );
if( Mathf.Sign( num1 ) != Mathf.Sign( preScale.x ) )
{
num1 = preScale.x * handleSize * 0.001f;
if( !allowNegative ) if( Mathf.Abs( num1 ) < 0.001f ) num1 = 0.001f * Mathf.Sign( preScale.x );
}
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,70 @@
#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 setIconEnabled = annotation_util.GetMethod("SetIconEnabled", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Static);
// const int MONO_BEHAVIOR_CLASS_ID = 114; // https://docs.unity3d.com/Manual/ClassIDReference.html
// setIconEnabled.Invoke(null, new object[] { MONO_BEHAVIOR_CLASS_ID, type.Name, on ? 1 : 0 });
//}
//catch (System.Exception)
//{
//}
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 );
if( cls == type.Name )
{
setIconEnabled.Invoke( null, new object[] { cid, cls, on ? 1 : 0 } );
break;
}
}
#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

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 6e55f773ce1c1cd45b70bcad47cd3d78
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,13 @@
{
"name": "AD_FimpoPropertyAttr",
"references": [],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

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

View File

@@ -0,0 +1,20 @@
using UnityEngine;
public class FPD_FixedCurveWindowAttribute : PropertyAttribute
{
public float StartTime;
public float EndTime;
public float StartValue;
public float EndValue;
public Color Color;
public FPD_FixedCurveWindowAttribute(float startTime = 0f, float startValue = 0f, float endTime = 1f, float endValue = 1f, float r = 0f, float g = 1f, float b = 1f, float a = 1f)
{
StartTime = startTime;
StartValue = startValue;
EndTime = endTime;
EndValue = endValue;
Color = new Color(r, g, b, a);
}
}

View File

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

View File

@@ -0,0 +1,19 @@
using UnityEngine;
public class FPD_HeaderAttribute : PropertyAttribute
{
public string HeaderText;
public float UpperPadding;
public float BottomPadding;
public float Height;
public FPD_HeaderAttribute(string headerText, float upperPadding = 6f, float bottomPadding = 4f, int addHeight = 2)
{
HeaderText = headerText;
UpperPadding = upperPadding;
BottomPadding = bottomPadding;
Height = addHeight;
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 54520e97577b06e4c98c18a19acf3c89
timeCreated: 1594666879
licenseType: Store
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,5 @@
using UnityEngine;
public class FPD_LayersAttribute : PropertyAttribute
{
}

View File

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

View File

@@ -0,0 +1,31 @@
using UnityEngine;
public class FPD_SuffixAttribute : PropertyAttribute
{
public readonly float Min;
public readonly float Max;
public readonly SuffixMode Mode;
public readonly string Suffix;
public readonly bool editableValue;
public readonly int widerField = 0;
public enum SuffixMode
{
From0to100,
PercentageUnclamped,
FromMinToMax,
FromMinToMaxRounded
}
// °
public FPD_SuffixAttribute(float min, float max, SuffixMode mode = SuffixMode.From0to100, string suffix = "%", bool editable = true, int wider = 0)
{
Min = min;
Max = max;
Mode = mode;
Suffix = suffix;
editableValue = editable;
widerField = wider;
}
}

View File

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