添加插件
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:
|
||||
@@ -0,0 +1,9 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 33dc52977f400d3419d2774a68a798c1
|
||||
folderAsset: yes
|
||||
timeCreated: 1602707605
|
||||
licenseType: Store
|
||||
DefaultImporter:
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,105 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FIMSpace.FEditor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(FPropDrawers_DrawScriptableAttribute))]
|
||||
public class FPropDrawers_DrawScriptableDrawer : PropertyDrawer
|
||||
{
|
||||
bool showProperty = false;
|
||||
float DrawerHeight = 0;
|
||||
string button = "►";
|
||||
|
||||
// Draw the property inside the given rect
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var e = Editor.CreateEditor(property.objectReferenceValue);
|
||||
var indent = EditorGUI.indentLevel;
|
||||
Rect temp = new Rect(position.x, position.y, 20, 16);
|
||||
|
||||
if (GUI.Button(temp, button))
|
||||
if (showProperty)
|
||||
{
|
||||
showProperty = false;
|
||||
button = "►";
|
||||
}
|
||||
else
|
||||
{
|
||||
showProperty = true;
|
||||
button = "▼";
|
||||
}
|
||||
|
||||
DrawerHeight = 0;
|
||||
position.height = 16;
|
||||
position.x += 20;
|
||||
position.width -= 20;
|
||||
EditorGUI.PropertyField(position, property);
|
||||
position.width += 20;
|
||||
position.x -= 20;
|
||||
position.y += 20;
|
||||
|
||||
if (!showProperty) return;
|
||||
if (e != null)
|
||||
{
|
||||
position.x += 20;
|
||||
position.width -= 40;
|
||||
|
||||
var so = e.serializedObject;
|
||||
so.Update();
|
||||
|
||||
var prop = so.GetIterator();
|
||||
prop.NextVisible(true);
|
||||
|
||||
int depthChilden = 0;
|
||||
bool showChilden = false;
|
||||
|
||||
while (prop.NextVisible(true))
|
||||
{
|
||||
if (prop.depth == 0) { showChilden = false; depthChilden = 0; }
|
||||
|
||||
if (showChilden && prop.depth > depthChilden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
position.height = 16;
|
||||
EditorGUI.indentLevel = indent + prop.depth;
|
||||
if (EditorGUI.PropertyField(position, prop))
|
||||
{
|
||||
showChilden = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
showChilden = true;
|
||||
depthChilden = prop.depth;
|
||||
}
|
||||
|
||||
position.y += 20;
|
||||
SetDrawerHeight(20);
|
||||
}
|
||||
|
||||
if (GUI.changed)
|
||||
{
|
||||
so.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
|
||||
{
|
||||
float height = base.GetPropertyHeight(property, label);
|
||||
height += DrawerHeight;
|
||||
return height;
|
||||
}
|
||||
|
||||
void SetDrawerHeight(float height)
|
||||
{
|
||||
DrawerHeight += height;
|
||||
}
|
||||
}
|
||||
|
||||
public class FPropDrawers_DrawScriptableAttribute : PropertyAttribute
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 517ef6dd0c387d848abb63a8ed55882a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,107 @@
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
|
||||
namespace FIMSpace.FEditor
|
||||
{
|
||||
[CustomPropertyDrawer(typeof(FPD_OverridableFloatAttribute))]
|
||||
public class FPD_OverridableFloat : PropertyDrawer
|
||||
{
|
||||
FPD_OverridableFloatAttribute Attribute { get { return ((FPD_OverridableFloatAttribute)base.attribute); } }
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
var boolProp = property.serializedObject.FindProperty(Attribute.BoolVarName);
|
||||
var valProp = property.serializedObject.FindProperty(Attribute.TargetVarName);
|
||||
|
||||
Color disabled = new Color(0.8f, 0.8f, 0.8f, 0.6f);
|
||||
Color preCol = GUI.color;
|
||||
if (!boolProp.boolValue) GUI.color = disabled; else GUI.color = preCol;
|
||||
|
||||
EditorGUI.BeginProperty(position, label, property);
|
||||
|
||||
var boolRect = new Rect(position.x, position.y, Attribute.LabelWidth + 15f, position.height);
|
||||
|
||||
EditorGUIUtility.labelWidth = Attribute.LabelWidth;
|
||||
EditorGUI.PrefixLabel(position, label);
|
||||
EditorGUI.PropertyField(boolRect, boolProp);
|
||||
|
||||
EditorGUIUtility.labelWidth = 14;
|
||||
var valRect = new Rect(position.x + Attribute.LabelWidth + 15, position.y, position.width - (Attribute.LabelWidth + 15), position.height);
|
||||
EditorGUI.PropertyField(valRect, valProp, new GUIContent(" "));
|
||||
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
|
||||
GUI.color = preCol;
|
||||
EditorGUI.EndProperty();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
|
||||
|
||||
[CustomPropertyDrawer(typeof(BackgroundColorAttribute))]
|
||||
public class BackgroundColorDecorator : DecoratorDrawer
|
||||
{
|
||||
BackgroundColorAttribute Attribute { get { return ((BackgroundColorAttribute)base.attribute); } }
|
||||
public override float GetHeight() { return 0; }
|
||||
|
||||
public override void OnGUI(Rect position)
|
||||
{
|
||||
GUI.backgroundColor = Attribute.Color;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
|
||||
[CustomPropertyDrawer(typeof(FPD_WidthAttribute))]
|
||||
public class FPD_Width : PropertyDrawer
|
||||
{
|
||||
FPD_WidthAttribute Attribute { get { return ((FPD_WidthAttribute)base.attribute); } }
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUIUtility.labelWidth = Attribute.LabelWidth;
|
||||
EditorGUI.PrefixLabel(position, label);
|
||||
EditorGUI.PropertyField(position, property);
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
[CustomPropertyDrawer(typeof(FPD_IndentAttribute))]
|
||||
public class FPD_Indent : PropertyDrawer
|
||||
{
|
||||
FPD_IndentAttribute Attribute { get { return ((FPD_IndentAttribute)base.attribute); } }
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
EditorGUIUtility.labelWidth = Attribute.LabelsWidth;
|
||||
for (int i = 0; i < Attribute.IndentCount; i++) EditorGUI.indentLevel++;
|
||||
EditorGUI.PrefixLabel(position, label);
|
||||
EditorGUI.PropertyField(position, property);
|
||||
for (int i = 0; i < Attribute.IndentCount; i++) EditorGUI.indentLevel--;
|
||||
EditorGUIUtility.labelWidth = 0;
|
||||
GUILayout.Space(Attribute.SpaceAfter);
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------- Next F Property Drawer -------------------------- \\
|
||||
|
||||
[CustomPropertyDrawer(typeof(FPD_HorizontalLineAttribute))]
|
||||
public class FPD_HorizontalLine : PropertyDrawer
|
||||
{
|
||||
FPD_HorizontalLineAttribute Attribute { get { return ((FPD_HorizontalLineAttribute)base.attribute); } }
|
||||
|
||||
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
|
||||
{
|
||||
FGUI_Inspector.DrawUILine(Attribute.color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b65c850de06f12c4aa781383b5a038cd
|
||||
timeCreated: 1543091521
|
||||
licenseType: Store
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -21,29 +21,6 @@ namespace FIMSpace.FEditor
|
||||
public static Object LastObjSelected;
|
||||
public static GameObject LastGameObjectSelected;
|
||||
|
||||
|
||||
/// <summary> Since remembering in which EditorGUI, EditorGUILayout, or EditorGUIUtility, or GUILayoutUtility ahhh... in which if these classes you will find the desired variable is so confusing ¯\_(ツ)_/¯ each time when trying finding it, ending in googling for forums post with it </summary>
|
||||
public static float InspectorViewWidth()
|
||||
{
|
||||
#if UNITY_EDITOR
|
||||
return EditorGUIUtility.currentViewWidth;
|
||||
#else
|
||||
return 0f;
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
public static bool IsRightMouseButton()
|
||||
{
|
||||
if (UnityEngine.Event.current == null) return false;
|
||||
|
||||
if (UnityEngine.Event.current.type == UnityEngine.EventType.Used)
|
||||
if (UnityEngine.Event.current.button == 1 || UnityEngine.Event.current.control)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void HeaderBox(ref bool foldout, string title, bool frame, Texture icon = null, int height = 20, int iconsSize = 19, bool big = false)
|
||||
{
|
||||
if (frame) EditorGUILayout.BeginHorizontal(FGUI_Resources.HeaderBoxStyle); else EditorGUILayout.BeginHorizontal();
|
||||
@@ -201,7 +178,7 @@ namespace FIMSpace.FEditor
|
||||
public static GUIStyle Style(Color bgColor, int off = -1)
|
||||
{
|
||||
GUIStyle newStyle = new GUIStyle(GUI.skin.box);
|
||||
if (off < 0) { if (Screen.dpi != 120) newStyle.border = new RectOffset(off, off, off, off); else if (!displayedDPIWarning) { /*Debug.Log("<b>[HEY! UNITY DEVELOPER!]</b> It seems you have setted up incorrect DPI settings for unity editor. Check <b>Unity.exe -> Properties -> Compatibility -> Change DPI Settings -> Replace Scaling -> System / System (Upgraded)</b> And restart Unity Editor.");*/ displayedDPIWarning = true; } }
|
||||
if (off < 0) { if (Screen.dpi != 120) newStyle.border = new RectOffset(off, off, off, off); else if (!displayedDPIWarning) { Debug.Log("<b>[HEY! UNITY DEVELOPER!]</b> It seems you have setted up incorrect DPI settings for unity editor. Check <b>Unity.exe -> Properties -> Compatibility -> Change DPI Settings -> Replace Scaling -> System / System (Upgraded)</b> And restart Unity Editor."); displayedDPIWarning = true; } }
|
||||
else newStyle.border = new RectOffset(off, off, off, off);
|
||||
|
||||
Color[] solidColor = new Color[1] { bgColor };
|
||||
|
||||
@@ -12,75 +12,50 @@ namespace FIMSpace.FEditor
|
||||
public static GUIStyle HeaderBoxStyle { get { if (__headerBoxStyle != null) return __headerBoxStyle; __headerBoxStyle = new GUIStyle(EditorStyles.helpBox); Texture2D bg = Resources.Load<Texture2D>("Fimp/Backgrounds/FHelpBox"); __headerBoxStyle.normal.background = bg; __headerBoxStyle.border = new RectOffset(6, 6, 6, 6); return __headerBoxStyle; } }
|
||||
private static GUIStyle __headerBoxStyle = null;
|
||||
|
||||
private static GUIStyle GenerateButtonStyle(string bg, string hover, string press, int lr = 3, int ud = 2)
|
||||
private static GUIStyle GenerateButtonStyle( string bg, string hover, string press, int lr = 3, int ud = 2 )
|
||||
{
|
||||
var s = new GUIStyle(EditorStyles.label);
|
||||
var s = new GUIStyle( EditorStyles.label );
|
||||
s.fixedHeight = 0;
|
||||
s.imagePosition = ImagePosition.ImageLeft;
|
||||
s.alignment = TextAnchor.MiddleCenter;
|
||||
s.border = new RectOffset(lr, lr, ud, ud);
|
||||
s.padding = new RectOffset(1, 1, 3, 3);
|
||||
s.margin = new RectOffset(0, 0, 0, 0);
|
||||
s.normal.background = Resources.Load<Texture2D>(bg);
|
||||
s.hover.background = Resources.Load<Texture2D>(hover);
|
||||
s.border = new RectOffset( lr, lr, ud, ud );
|
||||
s.padding = new RectOffset( 1, 1, 3, 3 );
|
||||
s.margin = new RectOffset( 0, 0, 0, 0 );
|
||||
s.normal.background = Resources.Load<Texture2D>( bg );
|
||||
s.hover.background = Resources.Load<Texture2D>( hover );
|
||||
s.focused.background = s.hover.background;
|
||||
s.active.background = Resources.Load<Texture2D>(press);
|
||||
s.active.background = Resources.Load<Texture2D>( press );
|
||||
return s;
|
||||
}
|
||||
|
||||
public static GUIStyle BUTTON1Style
|
||||
{
|
||||
get
|
||||
public static GUIStyle BUTTON2Style
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__bt2s != null) return __bt2s;
|
||||
|
||||
__bt2s = new GUIStyle(EditorStyles.label);
|
||||
__bt2s = new GUIStyle( EditorStyles.label );
|
||||
__bt2s.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
__bt2s.fixedHeight = 0;
|
||||
__bt2s.normal.background = Resources.Load<Texture2D>("Fimp/Backgrounds/FBG1");
|
||||
__bt2s.normal.background = Resources.Load<Texture2D>( "Fimp/Backgrounds/FBG1" );
|
||||
__bt2s.onNormal.background = __bt2s.normal.background;
|
||||
__bt2s.active.background = Resources.Load<Texture2D>("Fimp/Backgrounds/FBG1P");
|
||||
__bt2s.active.background = Resources.Load<Texture2D>( "Fimp/Backgrounds/FBG1P" );
|
||||
__bt2s.onActive.background = __bt2s.active.background;
|
||||
__bt2s.hover.background = Resources.Load<Texture2D>("Fimp/Backgrounds/FBG1H");
|
||||
__bt2s.hover.background = Resources.Load<Texture2D>( "Fimp/Backgrounds/FBG1H" );
|
||||
__bt2s.onHover.background = __bt2s.hover.background;
|
||||
__bt2s.border = new RectOffset(2, 2, 2, 2);
|
||||
__bt2s.contentOffset = new Vector2(0, 0);
|
||||
__bt2s.border = new RectOffset( 1, 1, 1, 1 );
|
||||
__bt2s.contentOffset = new Vector2( 0, 1 );
|
||||
return __bt2s;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static GUIStyle BUTTON2Style
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__bt2s != null) return __bt2s;
|
||||
|
||||
__bt2s = new GUIStyle(EditorStyles.label);
|
||||
__bt2s.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
__bt2s.fixedHeight = 0;
|
||||
__bt2s.normal.background = Resources.Load<Texture2D>("Fimp/Backgrounds/FBG1");
|
||||
__bt2s.onNormal.background = __bt2s.normal.background;
|
||||
__bt2s.active.background = Resources.Load<Texture2D>("Fimp/Backgrounds/FBG1P");
|
||||
__bt2s.onActive.background = __bt2s.active.background;
|
||||
__bt2s.hover.background = Resources.Load<Texture2D>("Fimp/Backgrounds/FBG1H");
|
||||
__bt2s.onHover.background = __bt2s.hover.background;
|
||||
__bt2s.border = new RectOffset(1, 1, 1, 1);
|
||||
__bt2s.contentOffset = new Vector2(0, 1);
|
||||
return __bt2s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static GUIStyle BUTTON2StyleU
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__bt2su != null) return __bt2su;
|
||||
__bt2su = new GUIStyle(BUTTON2Style);
|
||||
if( __bt2su != null ) return __bt2su;
|
||||
__bt2su = new GUIStyle( BUTTON2Style );
|
||||
__bt2su.imagePosition = ImagePosition.ImageAbove;
|
||||
__bt2su.contentOffset = new Vector2(0, 2);
|
||||
__bt2su.contentOffset = new Vector2(0,2);
|
||||
return __bt2su;
|
||||
}
|
||||
}
|
||||
@@ -89,29 +64,17 @@ namespace FIMSpace.FEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__bt3s != null) return __bt3s; __bt3s = new GUIStyle(EditorStyles.label);
|
||||
if( __bt3s != null ) return __bt3s; __bt3s = new GUIStyle( EditorStyles.label );
|
||||
__bt3s.alignment = TextAnchor.MiddleCenter;
|
||||
|
||||
__bt3s.fixedHeight = 0;
|
||||
__bt3s.normal.background = Resources.Load<Texture2D>("Fimp/Backgrounds/FBG2");
|
||||
__bt3s.border = new RectOffset(0, 0, 0, 0);
|
||||
__bt3s.contentOffset = new Vector2(0, 0);
|
||||
__bt3s.normal.background = Resources.Load<Texture2D>( "Fimp/Backgrounds/FBG2" );
|
||||
__bt3s.border = new RectOffset( 0, 0, 0, 0 );
|
||||
__bt3s.contentOffset = new Vector2( 0, 0 );
|
||||
return __bt3s;
|
||||
}
|
||||
}
|
||||
|
||||
public static GUIStyle BUTTONStyleU
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__bt2su != null) return __bt2su;
|
||||
__bt2su = new GUIStyle(ButtonStyle);
|
||||
__bt2su.imagePosition = ImagePosition.ImageAbove;
|
||||
__bt2su.contentOffset = new Vector2(0, 1);
|
||||
return __bt2su;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static GUIStyle __bt2s = null;
|
||||
private static GUIStyle __bt2su = null;
|
||||
@@ -138,14 +101,14 @@ namespace FIMSpace.FEditor
|
||||
{
|
||||
get
|
||||
{
|
||||
if (__buttStyle != null) return __buttStyle;
|
||||
__buttStyle = GenerateButtonStyle("Fimp/Backgrounds/Fbutton", "Fimp/Backgrounds/FbuttonHover", "Fimp/Backgrounds/FbuttonPress");
|
||||
if( __buttStyle != null ) return __buttStyle;
|
||||
__buttStyle = GenerateButtonStyle( "Fimp/Backgrounds/Fbutton", "Fimp/Backgrounds/FbuttonHover", "Fimp/Backgrounds/FbuttonPress");
|
||||
return __buttStyle;
|
||||
}
|
||||
}
|
||||
|
||||
private static GUIStyle __buttStyle = null;
|
||||
public static GUIStyle ButtonStyleR { get { if (__buttStyler != null) return __buttStyler; __buttStyler = new GUIStyle(ButtonStyle); __buttStyler.richText = true; return __buttStyler; } }
|
||||
public static GUIStyle ButtonStyleR { get { if( __buttStyler != null ) return __buttStyler; __buttStyler = new GUIStyle( ButtonStyle ); __buttStyler.richText = true; return __buttStyler; } }
|
||||
private static GUIStyle __buttStyler = null;
|
||||
|
||||
/// Text Styles ----------------------------------------------------
|
||||
@@ -357,16 +320,16 @@ namespace FIMSpace.FEditor
|
||||
public static Texture2D Tex_Prepare { get { if (__texPrep != null) return __texPrep; __texPrep = Resources.Load<Texture2D>("Fimp/Small Icons/FPrepare"); return __texPrep; } }
|
||||
private static Texture2D __texPrep = null;
|
||||
|
||||
public static Texture2D Tex_Anchor { get { if (__texAnchor != null) return __texAnchor; __texAnchor = Resources.Load<Texture2D>("Fimp/Small Icons/Anchor"); return __texAnchor; } }
|
||||
public static Texture2D Tex_Anchor { get { if( __texAnchor != null ) return __texAnchor; __texAnchor = Resources.Load<Texture2D>( "Fimp/Small Icons/Anchor" ); return __texAnchor; } }
|
||||
private static Texture2D __texAnchor = null;
|
||||
|
||||
public static Texture2D Tex_FAnimator { get { if (__texFAnimator != null) return __texFAnimator; __texFAnimator = Resources.Load<Texture2D>("Fimp/Small Icons/Fanimator"); return __texFAnimator; } }
|
||||
public static Texture2D Tex_FAnimator { get { if( __texFAnimator != null ) return __texFAnimator; __texFAnimator = Resources.Load<Texture2D>( "Fimp/Small Icons/Fanimator" ); return __texFAnimator; } }
|
||||
private static Texture2D __texFAnimator = null;
|
||||
|
||||
public static Texture2D Tex_FCorrect { get { if (__texFCorrect != null) return __texFCorrect; __texFCorrect = Resources.Load<Texture2D>("Fimp/Small Icons/FCorrect"); return __texFCorrect; } }
|
||||
public static Texture2D Tex_FCorrect { get { if( __texFCorrect != null ) return __texFCorrect; __texFCorrect = Resources.Load<Texture2D>( "Fimp/Small Icons/FCorrect" ); return __texFCorrect; } }
|
||||
private static Texture2D __texFCorrect = null;
|
||||
|
||||
public static Texture2D Tex_Symmetry { get { if (__texSymm != null) return __texSymm; __texSymm = Resources.Load<Texture2D>("Fimp/Small Icons/Symmetry"); return __texSymm; } }
|
||||
public static Texture2D Tex_Symmetry { get { if( __texSymm != null ) return __texSymm; __texSymm = Resources.Load<Texture2D>( "Fimp/Small Icons/Symmetry" ); return __texSymm; } }
|
||||
private static Texture2D __texSymm = null;
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user