添加插件
This commit is contained in:
@@ -13,16 +13,16 @@ public static class FEditor_TransformHandles
|
||||
/// [To be executed in OnSceneGUI()]
|
||||
/// Drawing sphere handle in scene view with controll ability
|
||||
/// </summary>
|
||||
public static Vector3 DrawAndSetPositionForHandle( Vector3 position, Transform rootReference )
|
||||
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;
|
||||
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 );
|
||||
float size = HandleUtility.GetHandleSize(position) * 0.125f;
|
||||
Handles.SphereHandleCap(0, position, rotation, size, UnityEngine.EventType.Repaint);
|
||||
Vector3 pos = Handles.PositionHandle(position, rotation);
|
||||
|
||||
return pos;
|
||||
}
|
||||
@@ -32,17 +32,17 @@ public static class FEditor_TransformHandles
|
||||
/// 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 = "" )
|
||||
public static bool DrawSphereHandle(Vector3 position, string text = "")
|
||||
{
|
||||
bool clicked = false;
|
||||
|
||||
if( Event.current.button != 1 )
|
||||
if (Event.current.button != 1)
|
||||
{
|
||||
Handles.color = Color.white;
|
||||
|
||||
float size = HandleUtility.GetHandleSize( position ) * 0.2f;
|
||||
float size = HandleUtility.GetHandleSize(position) * 0.2f;
|
||||
|
||||
if( Handles.Button( position, Quaternion.identity, size, size, Handles.SphereHandleCap ) )
|
||||
if (Handles.Button(position, Quaternion.identity, size, size, Handles.SphereHandleCap))
|
||||
{
|
||||
clicked = true;
|
||||
InternalEditorUtility.RepaintAllViews();
|
||||
@@ -50,17 +50,17 @@ public static class FEditor_TransformHandles
|
||||
|
||||
Handles.BeginGUI();
|
||||
|
||||
Vector2 labelSize = new Vector2( EditorGUIUtility.singleLineHeight * 2, EditorGUIUtility.singleLineHeight );
|
||||
Vector2 labelPos = HandleUtility.WorldToGUIPoint( position );
|
||||
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 ) );
|
||||
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.Label(new GUIContent(text), style);
|
||||
GUILayout.EndArea();
|
||||
|
||||
Handles.EndGUI();
|
||||
@@ -72,70 +72,45 @@ public static class FEditor_TransformHandles
|
||||
|
||||
|
||||
|
||||
public static Quaternion RotationHandle( Quaternion rotation, Vector3 position, float size = 1f, bool worldScale = false )
|
||||
public static Quaternion RotationHandle(Quaternion rotation, Vector3 position, float size = 1f, bool worldScale = false)
|
||||
{
|
||||
float handleSize = size;
|
||||
if( worldScale ) handleSize = HandleUtility.GetHandleSize( position ) * 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 );
|
||||
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 );
|
||||
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 );
|
||||
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 );
|
||||
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 )
|
||||
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 (worldScale) handleSize = HandleUtility.GetHandleSize(position) * size;
|
||||
|
||||
Vector3 preScale = scale;
|
||||
|
||||
if( !scaleAll )
|
||||
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.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 );
|
||||
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() )
|
||||
if (EditorGUI.EndChangeCheck())
|
||||
{
|
||||
float num2 = num1 / scale.x;
|
||||
scale.x = num1;
|
||||
@@ -146,24 +121,24 @@ public static class FEditor_TransformHandles
|
||||
return scale;
|
||||
}
|
||||
|
||||
public static Vector3 PositionHandle( Vector3 position, Quaternion rotation, float size = 1f, bool worldScale = false, bool freeHandle = true, bool colorize = true )
|
||||
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;
|
||||
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 (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 )
|
||||
if (freeHandle)
|
||||
{
|
||||
Handles.color = Handles.centerColor;
|
||||
position = Handles.FreeMoveHandle( position, handleSize * 0.15f, Vector3.one * 0.001f, Handles.RectangleHandleCap );
|
||||
position = Handles.FreeMoveHandle(position, rotation, handleSize * 0.15f, Vector3.one * 0.001f, Handles.RectangleHandleCap);
|
||||
}
|
||||
|
||||
Handles.color = color;
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
using UnityEngine;
|
||||
|
||||
|
||||
public class FPD_OverridableFloatAttribute : PropertyAttribute
|
||||
{
|
||||
public string BoolVarName;
|
||||
public string TargetVarName;
|
||||
public int LabelWidth;
|
||||
|
||||
public FPD_OverridableFloatAttribute(string boolVariableName, string targetVariableName, int labelWidth = 90)
|
||||
{
|
||||
BoolVarName = boolVariableName;
|
||||
TargetVarName = targetVariableName;
|
||||
LabelWidth = labelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
|
||||
public class BackgroundColorAttribute : PropertyAttribute
|
||||
{
|
||||
public float r;
|
||||
public float g;
|
||||
public float b;
|
||||
public float a;
|
||||
|
||||
public BackgroundColorAttribute()
|
||||
{
|
||||
r = g = b = a = 1f;
|
||||
}
|
||||
|
||||
public BackgroundColorAttribute(float aR, float aG, float aB, float aA)
|
||||
{
|
||||
r = aR;
|
||||
g = aG;
|
||||
b = aB;
|
||||
a = aA;
|
||||
}
|
||||
|
||||
public Color Color { get { return new Color(r, g, b, a); } }
|
||||
}
|
||||
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
public class FPD_WidthAttribute : PropertyAttribute
|
||||
{
|
||||
public float LabelWidth;
|
||||
|
||||
public FPD_WidthAttribute(int labelWidth)
|
||||
{
|
||||
LabelWidth = labelWidth;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
public class FPD_IndentAttribute : PropertyAttribute
|
||||
{
|
||||
public int IndentCount = 1;
|
||||
public int LabelsWidth = 0;
|
||||
public int SpaceAfter = 0;
|
||||
|
||||
public FPD_IndentAttribute(int indent = 1, int labelsWidth = 0, int spaceAfter = 0)
|
||||
{
|
||||
IndentCount = indent;
|
||||
LabelsWidth = labelsWidth;
|
||||
SpaceAfter = spaceAfter;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
public class FPD_HorizontalLineAttribute : PropertyAttribute
|
||||
{
|
||||
public Color color;
|
||||
|
||||
public FPD_HorizontalLineAttribute(float r = 0.55f, float g = 0.55f, float b = 0.55f, float a = 0.7f)
|
||||
{
|
||||
color = new Color(r, g, b, a);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: dc27395774a5c5b49b7a62f316a65486
|
||||
timeCreated: 1554395276
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user