NodeScript+ 导入了个 UI Extend

Signed-off-by: TRADER_FOER <lhf190@outlook.com>
This commit is contained in:
2026-05-23 21:05:16 +08:00
parent 7ea1f1d8c3
commit 51878f15ae
531 changed files with 198095 additions and 144473 deletions

View File

@@ -0,0 +1,24 @@
///Credit ChoMPHi
///Sourced from - http://forum.unity3d.com/threads/accordion-type-layout.271818/
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(AccordionElement), true)]
public class AccordionElementEditor : ToggleEditor {
public override void OnInspectorGUI()
{
this.serializedObject.Update();
EditorGUILayout.PropertyField(this.serializedObject.FindProperty("m_MinHeight"));
this.serializedObject.ApplyModifiedProperties();
base.serializedObject.Update();
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_IsOn"));
EditorGUILayout.PropertyField(base.serializedObject.FindProperty("m_Interactable"));
base.serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 8882b502b0c65b24ba4623d6a383815b
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,77 @@
///Credit Jason Horsburgh
///Sourced from - https://bitbucket.org/UnityUIExtensions/unity-ui-extensions/issues/127/uilinerenderer-mesh-not-updating-in-editor
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(UILineRenderer))]
public class BezierLineRendererEditor : Editor
{
void OnSceneGUI()
{
UILineRenderer curveRenderer = target as UILineRenderer;
if (!curveRenderer || curveRenderer.drivenExternally || curveRenderer.Points == null || curveRenderer.Points.Length < 2)
{
return;
}
var oldMatrix = Handles.matrix;
var transform = curveRenderer.GetComponent<RectTransform>();
//Pivot must be 0,0 to edit
//transform.pivot = Vector2.zero;
Handles.matrix = transform.localToWorldMatrix;
var sizeX = curveRenderer.rectTransform.rect.width;
var sizeY = curveRenderer.rectTransform.rect.height;
var offsetX = -curveRenderer.rectTransform.pivot.x * sizeX;
var offsetY = -curveRenderer.rectTransform.pivot.y * sizeY;
Vector2[] points = new Vector2[curveRenderer.Points.Length];
for (int i = 0; i < curveRenderer.Points.Length; i++)
{
points[i] = curveRenderer.Points[i];
}
//Need to transform points to worldspace! when set to Relative
if (curveRenderer.RelativeSize)
{
for (int i = 0; i < points.Length; i++)
{
points[i] = new Vector2(points[i].x * sizeX + offsetX, points[i].y * sizeY + offsetY);
}
}
for (int i = 0; i < points.Length - 1; i += 2)
{
Handles.DrawLine(points[i], points[i + 1]);
}
for (int i = 0; i < points.Length; ++i)
{
using (var check = new EditorGUI.ChangeCheckScope())
{
var p = Handles.PositionHandle(points[i], Quaternion.identity);
if (check.changed)
{
Undo.RecordObject(curveRenderer, "Changed Curve Position");
if (curveRenderer.RelativeSize)
{
curveRenderer.Points[i] = new Vector2((p.x - offsetX) / sizeX, (p.y - offsetY) / sizeY);
}
else
{
curveRenderer.Points[i] = p;
}
curveRenderer.transform.gameObject.SetActive(false);
curveRenderer.transform.gameObject.SetActive(true);
}
}
}
Handles.matrix = oldMatrix;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 4ef6a0d3c3259384982ae3974fe7e618
timeCreated: 1492258093
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,67 @@
///Credit judah4
///Sourced from - http://forum.unity3d.com/threads/color-picker.267043/
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(BoxSlider), true)]
[CanEditMultipleObjects]
public class BoxSliderEditor : SelectableEditor
{
SerializedProperty m_HandleRect;
SerializedProperty m_MinValue;
SerializedProperty m_MaxValue;
SerializedProperty m_WholeNumbers;
SerializedProperty m_ValueX;
SerializedProperty m_ValueY;
SerializedProperty m_OnValueChanged;
protected override void OnEnable()
{
base.OnEnable();
m_HandleRect = serializedObject.FindProperty("m_HandleRect");
m_MinValue = serializedObject.FindProperty("m_MinValue");
m_MaxValue = serializedObject.FindProperty("m_MaxValue");
m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers");
m_ValueX = serializedObject.FindProperty("m_ValueX");
m_ValueY = serializedObject.FindProperty("m_ValueY");
m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.Space();
serializedObject.Update();
EditorGUILayout.PropertyField(m_HandleRect);
if (m_HandleRect.objectReferenceValue != null)
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_MinValue);
EditorGUILayout.PropertyField(m_MaxValue);
EditorGUILayout.PropertyField(m_WholeNumbers);
EditorGUILayout.Slider(m_ValueX, m_MinValue.floatValue, m_MaxValue.floatValue);
EditorGUILayout.Slider(m_ValueY, m_MinValue.floatValue, m_MaxValue.floatValue);
// Draw the event notification options
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_OnValueChanged);
}
else
{
EditorGUILayout.HelpBox("Specify a RectTransform for the slider fill or the slider handle or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

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

View File

@@ -0,0 +1,59 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIBezierCurve))]
[CanEditMultipleObjects]
public class CUIBezierCurveEditor : Editor
{
public override void OnInspectorGUI()
{
DrawDefaultInspector();
}
protected void OnSceneGUI()
{
CUIBezierCurve script = (CUIBezierCurve)this.target;
if (script.ControlPoints != null)
{
Vector3[] controlPoints = script.ControlPoints;
Transform handleTransform = script.transform;
Quaternion handleRotation = script.transform.rotation;
for (int p = 0; p < CUIBezierCurve.CubicBezierCurvePtNum; p++)
{
EditorGUI.BeginChangeCheck();
Vector3 newPt = Handles.DoPositionHandle(handleTransform.TransformPoint(controlPoints[p]), handleRotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Move Point");
EditorUtility.SetDirty(script);
controlPoints[p] = handleTransform.InverseTransformPoint(newPt);
script.Refresh();
}
}
Handles.color = Color.gray;
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[0]), handleTransform.TransformPoint(controlPoints[1]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[1]), handleTransform.TransformPoint(controlPoints[2]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[2]), handleTransform.TransformPoint(controlPoints[3]));
int sampleSize = 10;
Handles.color = Color.white;
for (int s = 0; s < sampleSize; s++)
{
Handles.DrawLine(handleTransform.TransformPoint(script.GetPoint((float)s / sampleSize)), handleTransform.TransformPoint(script.GetPoint((float)(s + 1) / sampleSize)));
}
script.EDITOR_ControlPoints = controlPoints;
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 40e01e4fb1e006b46a0f127c8a9907b3
timeCreated: 1485671367
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,187 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIGraphic), true)]
public class CUIGraphicEditor : Editor {
protected static bool isCurveGpFold = false;
protected Vector3[] reuse_Vector3s = new Vector3[4];
public override void OnInspectorGUI()
{
CUIGraphic script = (CUIGraphic)this.target;
EditorGUILayout.HelpBox("CurlyUI (CUI) should work with most of the Unity UI. For Image, use CUIImage; for Text, use CUIText; and for others (e.g. RawImage), use CUIGraphic", MessageType.Info);
if (script.UIGraphic == null)
{
EditorGUILayout.HelpBox("CUI is an extension to Unity's UI. You must set Ui Graphic with a Unity Graphic component (e.g. Image, Text, RawImage)", MessageType.Error);
}
else
{
if (script.UIGraphic is Image && script.GetType() != typeof(CUIImage))
{
EditorGUILayout.HelpBox("Although CUI components are generalized. It is recommended that for Image, use CUIImage", MessageType.Warning);
}
else if (script.UIGraphic is Text && script.GetType() != typeof(CUIText))
{
EditorGUILayout.HelpBox("Although CUI components are generalized. It is recommended that for Text, use CUIText", MessageType.Warning);
}
EditorGUILayout.HelpBox("Now that CUI is ready, change the control points of the top and bottom bezier curves to curve/morph the UI. Improve resolution when the UI seems to look poorly when curved/morphed should help.", MessageType.Info);
}
DrawDefaultInspector();
// draw the editor that shows the position ratio of all control points from the two bezier curves
isCurveGpFold = EditorGUILayout.Foldout(isCurveGpFold, "Curves Position Ratios");
if (isCurveGpFold)
{
EditorGUI.indentLevel++;
EditorGUILayout.LabelField("Top Curve");
EditorGUI.indentLevel++;
Vector3[] controlPoints = script.RefCurvesControlRatioPoints[1].array;
EditorGUI.BeginChangeCheck();
for (int p = 0; p < controlPoints.Length; p++)
{
reuse_Vector3s[p] = EditorGUILayout.Vector3Field(string.Format("Control Points {0}", p + 1), controlPoints[p]);
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Change Ratio Points");
EditorUtility.SetDirty(script);
System.Array.Copy(reuse_Vector3s, script.RefCurvesControlRatioPoints[1].array, controlPoints.Length);
script.UpdateCurveControlPointPositions();
}
EditorGUI.indentLevel--;
EditorGUILayout.LabelField("Bottom Curve");
EditorGUI.indentLevel++;
controlPoints = script.RefCurvesControlRatioPoints[0].array;
EditorGUI.BeginChangeCheck();
for (int p = 0; p < controlPoints.Length; p++)
{
reuse_Vector3s[p] = EditorGUILayout.Vector3Field(string.Format("Control Points {0}", p + 1), controlPoints[p]);
}
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Change Ratio Points");
EditorUtility.SetDirty(script);
System.Array.Copy(reuse_Vector3s, controlPoints, controlPoints.Length);
script.UpdateCurveControlPointPositions();
}
EditorGUI.indentLevel--;
EditorGUI.indentLevel--;
}
EditorGUILayout.Space();
if (GUILayout.Button("Fit Bezier curves to rect transform"))
{
Undo.RecordObject(script, "Fit to Rect Transform");
Undo.RecordObject(script.RefCurves[0], "Fit to Rect Transform");
Undo.RecordObject(script.RefCurves[1], "Fit to Rect Transform");
EditorUtility.SetDirty(script);
script.FixTextToRectTrans();
script.Refresh();
}
EditorGUILayout.Space();
// disable group to prevent allowing the reference be used when there is no reference CUI
EditorGUI.BeginDisabledGroup(script.RefCUIGraphic == null);
if (GUILayout.Button("Reference CUI component for curves"))
{
Undo.RecordObject(script, "Reference CUI");
Undo.RecordObject(script.RefCurves[0], "Reference CUI");
Undo.RecordObject(script.RefCurves[1], "Reference CUI");
EditorUtility.SetDirty(script);
script.ReferenceCUIForBCurves();
script.Refresh();
}
EditorGUILayout.HelpBox("Auto set the curves' control points by referencing another CUI. You need to set Ref CUI Graphic (e.g. CUIImage) first.", MessageType.Info);
EditorGUI.EndDisabledGroup();
}
protected virtual void OnSceneGUI()
{
// for CUITextEditor, allow using scene UI to change the control points of the bezier curves
CUIGraphic script = (CUIGraphic)this.target;
script.ReportSet();
for (int c = 0; c < script.RefCurves.Length; c++)
{
CUIBezierCurve curve = script.RefCurves[c];
if (curve.ControlPoints != null)
{
Vector3[] controlPoints = curve.ControlPoints;
Transform handleTransform = curve.transform;
Quaternion handleRotation = curve.transform.rotation;
for (int p = 0; p < CUIBezierCurve.CubicBezierCurvePtNum; p++)
{
EditorGUI.BeginChangeCheck();
Handles.Label(handleTransform.TransformPoint(controlPoints[p]), string.Format("Control Point {0}", p + 1));
Vector3 newPt = Handles.DoPositionHandle(handleTransform.TransformPoint(controlPoints[p]), handleRotation);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(curve, "Move Point");
Undo.RecordObject(script, "Move Point");
EditorUtility.SetDirty(curve);
controlPoints[p] = handleTransform.InverseTransformPoint(newPt);
}
}
Handles.color = Color.gray;
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[0]), handleTransform.TransformPoint(controlPoints[1]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[1]), handleTransform.TransformPoint(controlPoints[2]));
Handles.DrawLine(handleTransform.TransformPoint(controlPoints[2]), handleTransform.TransformPoint(controlPoints[3]));
int sampleSize = 10;
Handles.color = Color.white;
for (int s = 0; s < sampleSize; s++)
{
Handles.DrawLine(handleTransform.TransformPoint(curve.GetPoint((float)s / sampleSize)), handleTransform.TransformPoint(curve.GetPoint((float)(s + 1) / sampleSize)));
}
curve.EDITOR_ControlPoints = controlPoints;
}
}
if (script.RefCurves != null)
{
Handles.DrawLine(script.RefCurves[0].transform.TransformPoint(script.RefCurves[0].ControlPoints[0]), script.RefCurves[1].transform.TransformPoint(script.RefCurves[1].ControlPoints[0]));
Handles.DrawLine(script.RefCurves[0].transform.TransformPoint(script.RefCurves[0].ControlPoints[3]), script.RefCurves[1].transform.TransformPoint(script.RefCurves[1].ControlPoints[3]));
}
script.Refresh();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: b7b84624f1ba7bd49b6cfc63b25f4b7c
timeCreated: 1485671367
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,93 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIImage))]
public class CUIImageEditor : CUIGraphicEditor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
CUIImage script = (CUIImage)this.target;
EditorGUILayout.Space();
EditorGUI.BeginChangeCheck();
EditorGUI.BeginDisabledGroup(!(script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Tiled));
Vector2 newCornerRatio = EditorGUILayout.Vector2Field("Corner Ratio", script.cornerPosRatio);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Change Corner Ratio");
EditorUtility.SetDirty(script);
script.cornerPosRatio = newCornerRatio;
}
if (GUILayout.Button("Use native corner ratio"))
{
Undo.RecordObject(script, "Change Corner Ratio");
EditorUtility.SetDirty(script);
script.cornerPosRatio = script.OriCornerPosRatio;
}
if (script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Filled)
{
EditorGUILayout.HelpBox("With CUIImage, you can also adjust the size of the corners for filled or sliced Image. The grey sphere in the editor scene could also be moved to change the corner's size.", MessageType.Info);
}
else
{
EditorGUILayout.HelpBox("With CUIImage, you can also adjust the size of the corners for filled or sliced Image. You need to set Image to filled or sliced to use this feature.", MessageType.Info);
}
EditorGUI.EndDisabledGroup();
}
protected override void OnSceneGUI()
{
base.OnSceneGUI();
CUIImage script = (CUIImage)this.target;
if (script.UIImage.type == Image.Type.Sliced || script.UIImage.type == Image.Type.Tiled)
{
Vector3 cornerPos = Vector3.zero;//
if (script.IsCurved)
{
cornerPos = script.GetBCurveSandwichSpacePoint(script.cornerPosRatio.x, script.cornerPosRatio.y);
}
else
{
cornerPos.x = script.cornerPosRatio.x * script.RectTrans.rect.width - script.RectTrans.pivot.x * script.RectTrans.rect.width;
cornerPos.y = script.cornerPosRatio.y * script.RectTrans.rect.height - script.RectTrans.pivot.y * script.RectTrans.rect.height;
}
Handles.color = Color.gray;
EditorGUI.BeginChangeCheck();
#if UNITY_2022_1_OR_NEWER
Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap);
#else
Vector3 newCornerPos = Handles.FreeMoveHandle(script.transform.TransformPoint(cornerPos), script.transform.rotation, HandleUtility.GetHandleSize(script.transform.TransformPoint(cornerPos)) / 7, Vector3.one, Handles.SphereHandleCap);
#endif
Handles.Label(newCornerPos, string.Format("Corner Mover"));
newCornerPos = script.transform.InverseTransformPoint(newCornerPos);
if (EditorGUI.EndChangeCheck())
{
Undo.RecordObject(script, "Move Corner");
EditorUtility.SetDirty(script);
script.cornerPosRatio = new Vector2(newCornerPos.x, newCornerPos.y);
script.cornerPosRatio.x = (script.cornerPosRatio.x + script.RectTrans.pivot.x * script.RectTrans.rect.width) / script.RectTrans.rect.width;
script.cornerPosRatio.y = (script.cornerPosRatio.y + script.RectTrans.pivot.y * script.RectTrans.rect.height) / script.RectTrans.rect.height;
}
}
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 8445204f2ee16e0408274b8400deef53
timeCreated: 1485929052
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,10 @@
/// Credit Titinious (https://github.com/Titinious)
/// Sourced from - https://github.com/Titinious/CurlyUI
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(CUIText))]
public class CUITextEditor : CUIGraphicEditor { }
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 041976c43b8439747a030b45a4712b77
timeCreated: 1485929052
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,120 @@
/// Credit dakka
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/#post-1752415
/// Notes - Mod from Yilmaz Kiymaz's editor scripts presentation at Unite 2013
/// Updated simonDarksideJ - removed Linq use, not required.
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
public class CanvasGroupActivator : EditorWindow
{
[MenuItem("Window/UI/Extensions/Canvas Groups Activator")]
public static void InitWindow()
{
EditorWindow.GetWindow<CanvasGroupActivator>();
}
CanvasGroup[] canvasGroups;
void OnEnable()
{
ObtainCanvasGroups();
}
void OnFocus()
{
ObtainCanvasGroups();
}
void ObtainCanvasGroups()
{
#if UNITY_2023_1_OR_NEWER
canvasGroups = GameObject.FindObjectsByType<CanvasGroup>(FindObjectsSortMode.None);
#else
canvasGroups = GameObject.FindObjectsOfType<CanvasGroup>();
#endif
}
void OnGUI()
{
if (canvasGroups == null)
{
return;
}
GUILayout.Space(10f);
GUILayout.Label("Canvas Groups");
for (int i = 0; i < canvasGroups.Length; i++)
{
if (canvasGroups[i] == null) { continue; }
bool initialActive = false;
if (canvasGroups[i].alpha == 1.0f)
initialActive = true;
bool active = EditorGUILayout.Toggle(canvasGroups[i].name, initialActive);
if (active != initialActive)
{
//If deactivated and initially active
if (!active && initialActive)
{
//Deactivate this
canvasGroups[i].alpha = 0f;
canvasGroups[i].interactable = false;
canvasGroups[i].blocksRaycasts = false;
}
//If activated and initially deactivate
else if (active && !initialActive)
{
//Deactivate all others and activate this
HideAllGroups();
canvasGroups[i].alpha = 1.0f;
canvasGroups[i].interactable = true;
canvasGroups[i].blocksRaycasts = true;
}
}
}
GUILayout.Space(5f);
if (GUILayout.Button("Show All"))
{
ShowAllGroups();
}
if (GUILayout.Button("Hide All"))
{
HideAllGroups();
}
}
void ShowAllGroups()
{
foreach (var group in canvasGroups)
{
if (group != null)
{
group.alpha = 1.0f;
group.interactable = true;
group.blocksRaycasts = true;
}
}
}
void HideAllGroups()
{
foreach (var group in canvasGroups)
{
if (group != null)
{
group.alpha = 0;
group.interactable = false;
group.blocksRaycasts = false;
}
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: f60a419e63d329f43ba1bf57e98b34bf
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,28 @@
using UnityEngine;
using UnityEditor;
namespace UnityEngine.UI.Extensions.ColorPicker
{
[CustomEditor(typeof(ColorPickerPresets))]
public class ColorPickerPresetsEditor : Editor
{
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
var colorPickerPresets = (ColorPickerPresets)target;
if (colorPickerPresets.saveMode != ColorPickerPresets.SaveType.JsonFile)
return;
string fileLocation = colorPickerPresets.JsonFilePath;
if (!System.IO.File.Exists(fileLocation))
return;
if (GUILayout.Button("Open JSON file."))
{
Application.OpenURL(fileLocation);
}
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,119 @@
/// Credit setchi (https://github.com/setchi)
/// Sourced from - https://github.com/setchi/FancyScrollView
using UnityEditor;
using UnityEditor.AnimatedValues;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(Scroller))]
[CanEditMultipleObjects]
public class ScrollerEditor : Editor
{
SerializedProperty viewport;
SerializedProperty scrollDirection;
SerializedProperty movementType;
SerializedProperty elasticity;
SerializedProperty scrollSensitivity;
SerializedProperty inertia;
SerializedProperty decelerationRate;
SerializedProperty snap;
SerializedProperty draggable;
SerializedProperty scrollbar;
AnimBool showElasticity;
AnimBool showInertiaRelatedValues;
void OnEnable()
{
viewport = serializedObject.FindProperty("viewport");
scrollDirection = serializedObject.FindProperty("scrollDirection");
movementType = serializedObject.FindProperty("movementType");
elasticity = serializedObject.FindProperty("elasticity");
scrollSensitivity = serializedObject.FindProperty("scrollSensitivity");
inertia = serializedObject.FindProperty("inertia");
decelerationRate = serializedObject.FindProperty("decelerationRate");
snap = serializedObject.FindProperty("snap");
draggable = serializedObject.FindProperty("draggable");
scrollbar = serializedObject.FindProperty("scrollbar");
showElasticity = new AnimBool(Repaint);
showInertiaRelatedValues = new AnimBool(Repaint);
SetAnimBools(true);
}
void OnDisable()
{
showElasticity.valueChanged.RemoveListener(Repaint);
showInertiaRelatedValues.valueChanged.RemoveListener(Repaint);
}
void SetAnimBools(bool instant)
{
SetAnimBool(showElasticity, !movementType.hasMultipleDifferentValues && movementType.enumValueIndex == (int)MovementType.Elastic, instant);
SetAnimBool(showInertiaRelatedValues, !inertia.hasMultipleDifferentValues && inertia.boolValue, instant);
}
void SetAnimBool(AnimBool a, bool value, bool instant)
{
if (instant)
{
a.value = value;
}
else
{
a.target = value;
}
}
public override void OnInspectorGUI()
{
SetAnimBools(false);
serializedObject.Update();
EditorGUILayout.PropertyField(viewport);
EditorGUILayout.PropertyField(scrollDirection);
EditorGUILayout.PropertyField(movementType);
DrawMovementTypeRelatedValue();
EditorGUILayout.PropertyField(scrollSensitivity);
EditorGUILayout.PropertyField(inertia);
DrawInertiaRelatedValues();
EditorGUILayout.PropertyField(draggable);
EditorGUILayout.PropertyField(scrollbar);
serializedObject.ApplyModifiedProperties();
}
void DrawMovementTypeRelatedValue()
{
using (var group = new EditorGUILayout.FadeGroupScope(showElasticity.faded))
{
if (!group.visible)
{
return;
}
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(elasticity);
}
}
}
void DrawInertiaRelatedValues()
{
using (var group = new EditorGUILayout.FadeGroupScope(showInertiaRelatedValues.faded))
{
if (!group.visible)
{
return;
}
using (new EditorGUI.IndentLevelScope())
{
EditorGUILayout.PropertyField(decelerationRate);
EditorGUILayout.PropertyField(snap);
}
}
}
}
}

View File

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

View File

@@ -0,0 +1,121 @@
///Credit brogan89
///Sourced from - https://github.com/brogan89/MinMaxSlider
using System;
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(MinMaxSlider), true)]
[CanEditMultipleObjects]
public class MinMaxSliderEditor : SelectableEditor
{
private SerializedProperty _customCamera;
private SerializedProperty _sliderBounds;
private SerializedProperty _minHandle;
private SerializedProperty _maxHandle;
private SerializedProperty _minText;
private SerializedProperty _maxText;
private SerializedProperty _textFormat;
private SerializedProperty _middleGraphic;
private SerializedProperty _minLimit;
private SerializedProperty _maxLimit;
private SerializedProperty _wholeNumbers;
private SerializedProperty _minValue;
private SerializedProperty _maxValue;
private SerializedProperty _onValueChanged;
private readonly GUIContent label = new GUIContent("Min Max Values");
protected override void OnEnable()
{
base.OnEnable();
_customCamera = serializedObject.FindProperty("customCamera");
_sliderBounds = serializedObject.FindProperty("sliderBounds");
_minHandle = serializedObject.FindProperty("minHandle");
_maxHandle = serializedObject.FindProperty("maxHandle");
_minText = serializedObject.FindProperty("minText");
_maxText = serializedObject.FindProperty("maxText");
_textFormat = serializedObject.FindProperty("textFormat");
_middleGraphic = serializedObject.FindProperty("middleGraphic");
_minLimit = serializedObject.FindProperty("minLimit");
_maxLimit = serializedObject.FindProperty("maxLimit");
_wholeNumbers = serializedObject.FindProperty("wholeNumbers");
_minValue = serializedObject.FindProperty("minValue");
_maxValue = serializedObject.FindProperty("maxValue");
_onValueChanged = serializedObject.FindProperty("onValueChanged");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
float minLimitOld = _minLimit.floatValue;
float maxLimitOld = _maxLimit.floatValue;
float minValueOld = _minValue.floatValue;
float maxValueOld = _maxValue.floatValue;
EditorGUILayout.PropertyField(_customCamera);
EditorGUILayout.PropertyField(_sliderBounds);
EditorGUILayout.PropertyField(_minHandle);
EditorGUILayout.PropertyField(_maxHandle);
EditorGUILayout.PropertyField(_middleGraphic);
EditorGUILayout.PropertyField(_minText);
EditorGUILayout.PropertyField(_maxText);
EditorGUILayout.PropertyField(_textFormat);
EditorGUILayout.PropertyField(_minLimit);
EditorGUILayout.PropertyField(_maxLimit);
EditorGUILayout.PropertyField(_wholeNumbers);
EditorGUILayout.PropertyField(_minValue);
EditorGUILayout.PropertyField(_maxValue);
float minValue = Mathf.Clamp(_minValue.floatValue, _minLimit.floatValue, _maxLimit.floatValue);
float maxValue = Mathf.Clamp(_maxValue.floatValue, _minLimit.floatValue, _maxLimit.floatValue);
EditorGUILayout.MinMaxSlider(label, ref minValue, ref maxValue, _minLimit.floatValue, _maxLimit.floatValue);
bool anyValueChanged = !IsEqualFloat(minValueOld, minValue)
|| !IsEqualFloat(maxValueOld, maxValue)
|| !IsEqualFloat(minLimitOld, _minLimit.floatValue)
|| !IsEqualFloat(maxLimitOld, _maxLimit.floatValue);
if (anyValueChanged)
{
MinMaxSlider slider = (MinMaxSlider)target;
// force limits to ints if whole numbers.
// needed to do this here because it wouldn't set in component script for some reason
if (slider.wholeNumbers)
{
_minLimit.floatValue = Mathf.RoundToInt(_minLimit.floatValue);
_maxLimit.floatValue = Mathf.RoundToInt(_maxLimit.floatValue);
}
// set slider values
slider.SetValues(minValue, maxValue, _minLimit.floatValue, _maxLimit.floatValue);
}
EditorGUILayout.Space();
EditorGUILayout.PropertyField(_onValueChanged);
serializedObject.ApplyModifiedProperties();
}
/// <summary>
/// Returns true if floating point numbers are within 0.01f (close enough to be considered equal)
/// </summary>
/// <param name="a"></param>
/// <param name="b"></param>
/// <returns></returns>
private static bool IsEqualFloat(float a, float b)
{
return Math.Abs(a - b) < 0.01f;
}
}
}

View File

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

View File

@@ -0,0 +1,21 @@
/// Credit Slipp Douglas Thompson
/// Sourced from - https://gist.github.com/capnslipp/349c18283f2fea316369
///
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CanEditMultipleObjects, CustomEditor(typeof(NonDrawingGraphic), false)]
public class NonDrawingGraphicEditor : GraphicEditor
{
public override void OnInspectorGUI()
{
base.serializedObject.Update();
EditorGUILayout.PropertyField(base.m_Script, new GUILayoutOption[0]);
// skipping AppearanceControlsGUI
base.RaycastControlsGUI();
base.serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: ee2802949feca4c4c934331b6a0dc379
timeCreated: 1483566748
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,134 @@
/// Credit Ben MacKinnon @Dover8
/// Sourced from - https://github.com/Dover8/Unity-UI-Extensions/tree/range-slider
/// Usage: Extension of the standard slider. Two handles determine a low and high value between a Min and Max.
/// Raises a UnityEvent passing the low and high values
using UnityEditor;
using UnityEditor.UI;
namespace UnityEngine.UI.Extensions
{
[CustomEditor(typeof(RangeSlider), true)]
[CanEditMultipleObjects]
public class RangeSliderEditor : SelectableEditor
{
SerializedProperty m_Direction;
SerializedProperty m_LowHandleRect;
SerializedProperty m_HighHandleRect;
SerializedProperty m_FillRect;
SerializedProperty m_MinValue;
SerializedProperty m_MaxValue;
SerializedProperty m_WholeNumbers;
SerializedProperty m_LowValue;
SerializedProperty m_HighValue;
//need ref values for the editor MinMaxSlider
float low = 0;
float high = 1;
SerializedProperty m_OnValueChanged;
protected override void OnEnable()
{
base.OnEnable();
m_LowHandleRect = serializedObject.FindProperty("m_LowHandleRect");
m_HighHandleRect = serializedObject.FindProperty("m_HighHandleRect");
m_FillRect = serializedObject.FindProperty("m_FillRect");
m_Direction = serializedObject.FindProperty("m_Direction");
m_MinValue = serializedObject.FindProperty("m_MinValue");
m_MaxValue = serializedObject.FindProperty("m_MaxValue");
m_WholeNumbers = serializedObject.FindProperty("m_WholeNumbers");
m_LowValue = serializedObject.FindProperty("m_LowValue");
low = m_LowValue.floatValue;
m_HighValue = serializedObject.FindProperty("m_HighValue");
high = m_HighValue.floatValue;
m_OnValueChanged = serializedObject.FindProperty("m_OnValueChanged");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
EditorGUILayout.Space();
serializedObject.Update();
//grab the updated value affected by m_WholeNumbers
low = m_LowValue.floatValue;
high = m_HighValue.floatValue;
EditorGUILayout.PropertyField(m_LowHandleRect);
EditorGUILayout.PropertyField(m_HighHandleRect);
EditorGUILayout.PropertyField(m_FillRect);
if (m_LowHandleRect.objectReferenceValue != null && m_HighHandleRect.objectReferenceValue != null)
{
EditorGUI.BeginChangeCheck();
EditorGUILayout.PropertyField(m_Direction);
if (EditorGUI.EndChangeCheck())
{
RangeSlider.Direction direction = (RangeSlider.Direction)m_Direction.enumValueIndex;
foreach (var obj in serializedObject.targetObjects)
{
RangeSlider rangeSlider = obj as RangeSlider;
rangeSlider.SetDirection(direction, true);
}
}
EditorGUILayout.PropertyField(m_MinValue);
EditorGUILayout.PropertyField(m_MaxValue);
EditorGUILayout.PropertyField(m_WholeNumbers);
//We're going to do a fair bit of layout here
EditorGUILayout.BeginHorizontal();
//Low Label and value
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label("Low");
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
low = EditorGUILayout.DelayedFloatField(low, GUILayout.MaxWidth(100));
EditorGUILayout.EndVertical();
GUILayout.FlexibleSpace();
//Slider
EditorGUILayout.BeginVertical();
GUILayout.FlexibleSpace();
EditorGUILayout.MinMaxSlider(ref low, ref high, m_MinValue.floatValue, m_MaxValue.floatValue, GUILayout.ExpandWidth(true));
EditorGUILayout.EndVertical();
GUILayout.FlexibleSpace();
//High label and value
EditorGUILayout.BeginVertical();
EditorGUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Label("High");
GUILayout.FlexibleSpace();
EditorGUILayout.EndHorizontal();
high = EditorGUILayout.DelayedFloatField(high, GUILayout.MaxWidth(100));
EditorGUILayout.EndVertical();
EditorGUILayout.EndHorizontal();
m_LowValue.floatValue = low;
m_HighValue.floatValue = high;
EditorGUILayout.Space();
EditorGUILayout.PropertyField(m_OnValueChanged);
}
else
{
EditorGUILayout.HelpBox("Specify a RectTransform for the RangeSlider fill or the RangeSlider handles or both. Each must have a parent RectTransform that it can slide within.", MessageType.Info);
}
serializedObject.ApplyModifiedProperties();
}
}
}

View File

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

View File

@@ -0,0 +1,19 @@
/// Credit tanoshimi
/// Sourced from - https://forum.unity3d.com/threads/read-only-fields.68976/
///
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CustomPropertyDrawer(typeof(ReadOnlyAttribute))]
public class ReadOnlyDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
GUI.enabled = false;
EditorGUI.PropertyField(position, property, label, true);
GUI.enabled = true;
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 33c90f5149877a242981372f6cde9a35
timeCreated: 1498392707
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,87 @@
/// Credit setchi (https://github.com/setchi)
/// Sourced from - https://github.com/setchi/FancyScrollView
// For maintenance, every new [SerializeField] variable in ScrollPositionController must be declared here
using System;
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[Obsolete("ScrollPositionController has been replaced by the Scroller component", true)]
[CustomEditor(typeof(ScrollPositionController))]
[CanEditMultipleObjects]
public class ScrollPositionControllerEditor : Editor
{
SerializedProperty viewport;
SerializedProperty directionOfRecognize;
SerializedProperty movementType;
SerializedProperty elasticity;
SerializedProperty scrollSensitivity;
SerializedProperty inertia;
SerializedProperty decelerationRate;
SerializedProperty snap;
SerializedProperty snapEnable;
SerializedProperty snapVelocityThreshold;
SerializedProperty snapDuration;
SerializedProperty dataCount;
void OnEnable()
{
viewport = serializedObject.FindProperty("viewport");
directionOfRecognize = serializedObject.FindProperty("directionOfRecognize");
movementType = serializedObject.FindProperty("movementType");
elasticity = serializedObject.FindProperty("elasticity");
scrollSensitivity = serializedObject.FindProperty("scrollSensitivity");
inertia = serializedObject.FindProperty("inertia");
decelerationRate = serializedObject.FindProperty("decelerationRate");
snap = serializedObject.FindProperty("snap");
snapEnable = serializedObject.FindProperty("snap.Enable");
snapVelocityThreshold = serializedObject.FindProperty("snap.VelocityThreshold");
snapDuration = serializedObject.FindProperty("snap.Duration");
dataCount = serializedObject.FindProperty("dataCount");
}
public override void OnInspectorGUI()
{
serializedObject.Update();
EditorGUILayout.PropertyField(viewport);
EditorGUILayout.PropertyField(directionOfRecognize);
EditorGUILayout.PropertyField(movementType);
EditorGUILayout.PropertyField(elasticity);
EditorGUILayout.PropertyField(scrollSensitivity);
EditorGUILayout.PropertyField(inertia);
DrawInertiaRelatedValues();
EditorGUILayout.PropertyField(dataCount);
serializedObject.ApplyModifiedProperties();
}
void DrawInertiaRelatedValues()
{
if (inertia.boolValue)
{
EditorGUILayout.PropertyField(decelerationRate);
EditorGUILayout.PropertyField(snap);
using (new EditorGUI.IndentLevelScope())
{
DrawSnapRelatedValues();
}
}
}
void DrawSnapRelatedValues()
{
if (snap.isExpanded)
{
EditorGUILayout.PropertyField(snapEnable);
if (snapEnable.boolValue)
{
EditorGUILayout.PropertyField(snapVelocityThreshold);
EditorGUILayout.PropertyField(snapDuration);
}
}
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 986fda6476737da458576709b7f59ea3
timeCreated: 1508699683
licenseType: Pro
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,38 @@
/// Credit drobina, w34edrtfg, playemgames
/// Sourced from - http://forum.unity3d.com/threads/sprite-icons-with-text-e-g-emoticons.265927/
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
[CanEditMultipleObjects]
[CustomEditor(typeof(TextPic))]
public class TextPicEditor : UnityEditor.UI.TextEditor
{
private SerializedProperty ImageScalingFactorProp;
private SerializedProperty hyperlinkColorProp;
private SerializedProperty imageOffsetProp;
private SerializedProperty iconList;
protected override void OnEnable()
{
base.OnEnable();
ImageScalingFactorProp = serializedObject.FindProperty("ImageScalingFactor");
hyperlinkColorProp = serializedObject.FindProperty("hyperlinkColor");
imageOffsetProp = serializedObject.FindProperty("imageOffset");
iconList = serializedObject.FindProperty("inspectorIconList");
}
public override void OnInspectorGUI()
{
base.OnInspectorGUI();
serializedObject.Update();
EditorGUILayout.PropertyField(imageOffsetProp, new GUIContent("Image Offset"));
EditorGUILayout.PropertyField(ImageScalingFactorProp, new GUIContent("Image Scaling Factor"));
EditorGUILayout.PropertyField(hyperlinkColorProp, new GUIContent("Hyperlink Color"));
EditorGUILayout.PropertyField(iconList, new GUIContent("Icon List"), true);
serializedObject.ApplyModifiedProperties();
}
}
}

View File

@@ -0,0 +1,12 @@
fileFormatVersion: 2
guid: 5fe8e67609bbee14d8ad0805aac72799
timeCreated: 1468515486
licenseType: Pro
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,130 @@
/*
The MIT License (MIT)
Copyright (c) 2017 Play-Em
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System;
using System.Collections;
namespace UnityEngine.UI.Extensions
{
public class TextPicIconEditor : EditorWindow {
[MenuItem("Window/UI/Extensions/TextPic Edit Icons")]
protected static void ShowTextPicIconEditor() {
var wnd = GetWindow<TextPicIconEditor>();
wnd.titleContent.text = "Edit Icons in TextPic";
wnd.Show();
}
private GameObject o;
private static int columnWidth = 300;
private string iconName;
private Sprite icon;
public void Swap(GameObject o) {
#if UNITY_EDITOR
Debug.Log("Editing icons for " + o.name);
TextPic[] children = o.GetComponentsInChildren<TextPic>(true);
for(int i = 0; i < children.Length; i++) {
if (children[i] != null) {
for (int j = 0; j < children[i].inspectorIconList.Length; j++) {
if (!string.IsNullOrEmpty(iconName)
&& children[i].inspectorIconList[j].name == iconName) {
children[i].inspectorIconList[j].sprite = icon;
Debug.Log("Swapped icon for " + children[i].inspectorIconList[j].name);
}
}
children[i].ResetIconList();
Debug.Log("Swapped icons for " + children[i].name);
}
}
#endif
}
public void OnGUI() {
GUILayout.Label("Select a GameObject to edit TextPic icons", EditorStyles.boldLabel);
EditorGUILayout.Separator();
GUILayout.Label("GameObject", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
if (Selection.activeGameObject != null) {
o = Selection.activeGameObject;
}
EditorGUILayout.ObjectField(o, typeof(GameObject), true);
EditorGUI.EndChangeCheck();
if (o != null) {
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Icon Name:", GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
iconName = EditorGUILayout.TextField(iconName, GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
GUILayout.Label("New Sprite:", GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
icon = (Sprite)EditorGUILayout.ObjectField(icon, typeof(Sprite), false, GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Edit Icons")) {
#if UNITY_EDITOR
Swap(o);
#endif
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
}
}
}
}

View File

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

View File

@@ -0,0 +1,140 @@
/*
The MIT License (MIT)
Copyright (c) 2017 Play-Em
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System;
using System.Collections;
using System.Collections.Generic;
namespace UnityEngine.UI.Extensions
{
public class TextPicIconListCopier : EditorWindow {
[MenuItem("Window/UI/Extensions/TextPic Copy Icon Lists")]
protected static void ShowTextPicIconListCopier() {
var wnd = GetWindow<TextPicIconListCopier>();
wnd.titleContent.text = "Copy Icons in TextPic";
wnd.Show();
}
private List<TextPic> textPicList = new List<TextPic>();
#if UNITY_EDITOR
void OnSelectionChange() {
if (Selection.objects.Length > 1 )
{
Debug.Log ("Length? " + Selection.objects.Length);
textPicList.Clear();
foreach ( Object o in Selection.objects ) {
if ( o is GameObject ) {
TextPic tp = ((GameObject)o).GetComponent<TextPic>();
if (tp != null) {
textPicList.Add(tp);
}
}
}
}
else if (Selection.activeObject is GameObject) {
textPicList.Clear();
TextPic tp = ((GameObject)Selection.activeObject).GetComponent<TextPic>();
if (tp != null) {
textPicList.Add(tp);
}
}
else {
textPicList.Clear();
}
this.Repaint();
}
#endif
private static int columnWidth = 300;
private TextPic textPic;
public void Copy() {
#if UNITY_EDITOR
foreach(TextPic tp in textPicList) {
if (tp != null) {
tp.inspectorIconList = new TextPic.IconName[textPic.inspectorIconList.Length];
textPic.inspectorIconList.CopyTo(tp.inspectorIconList, 0);
tp.ResetIconList();
Debug.Log("Copied icons to " + tp.name);
}
}
#endif
}
public void OnGUI() {
GUILayout.Label("TextPic to copy icons", EditorStyles.boldLabel);
EditorGUILayout.Separator();
GUILayout.Label("TextPic", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
textPic = EditorGUILayout.ObjectField(textPic, typeof(TextPic), true) as TextPic;
EditorGUI.EndChangeCheck();
if (textPicList.Count > 0) {
if ( textPicList.Count == 1 )
{
textPicList[0] = ((TextPic)EditorGUILayout.ObjectField(
textPicList[0],
typeof(TextPic),
true,
GUILayout.Width(columnWidth))
);
}
else
{
GUILayout.Label("Multiple TextPic: " + textPicList.Count, GUILayout.Width(columnWidth));
}
if (textPic != null) {
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Copy Icons")) {
#if UNITY_EDITOR
Copy();
#endif
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
}
}
else {
GUILayout.Label("Please select objects that have a TextPic component", EditorStyles.boldLabel);
}
}
}
}

View File

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

View File

@@ -0,0 +1,161 @@
/*
The MIT License (MIT)
Copyright (c) 2014 Play-Em
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
*/
using UnityEngine;
#if UNITY_EDITOR
using UnityEditor;
#endif
using System;
using System.Collections;
namespace UnityEngine.UI.Extensions
{
public class TextPicRenameEditor : EditorWindow {
[MenuItem("Window/UI/Extensions/TextPic Rename Icons and Text")]
protected static void ShowTextPicRenameEditor() {
var wnd = GetWindow<TextPicRenameEditor>();
wnd.titleContent.text = "Rename Icon List";
wnd.Show();
}
private GameObject o;
private static int columnWidth = 300;
private string prefix;
private string suffix;
private string originalText;
private string replacementText;
public void Rename(GameObject o) {
#if UNITY_EDITOR
Debug.Log("Changing icons and text for " + o.name);
TextPic[] children = o.GetComponentsInChildren<TextPic>(true);
for(int i = 0; i < children.Length; i++) {
if (children[i] != null) {
for (int j = 0; j < children[i].inspectorIconList.Length; j++) {
if (!string.IsNullOrEmpty(originalText)
&& children[i].inspectorIconList[j].name.Contains(originalText)) {
children[i].text.Replace(originalText, replacementText);
children[i].inspectorIconList[j].name = children[i].inspectorIconList[j].name.Replace(originalText, replacementText);
Debug.Log("Renamed icon for " + children[i].inspectorIconList[j].name);
}
if (!string.IsNullOrEmpty(prefix)
&& !string.IsNullOrEmpty(suffix)
&& !children[i].inspectorIconList[j].name.StartsWith(prefix)
&& !children[i].inspectorIconList[j].name.EndsWith(suffix)) {
children[i].text.Replace(children[i].inspectorIconList[j].name, prefix + children[i].inspectorIconList[j].name + suffix);
children[i].inspectorIconList[j].name = prefix + children[i].inspectorIconList[j].name + suffix;
Debug.Log("Renamed icon for " + children[i].inspectorIconList[j].name);
}
}
children[i].ResetIconList();
Debug.Log("Renamed icons for " + children[i].name);
}
}
#endif
}
public void OnGUI() {
GUILayout.Label("Select a GameObject to rename TextPic icons and text", EditorStyles.boldLabel);
EditorGUILayout.Separator();
GUILayout.Label("GameObject", EditorStyles.boldLabel);
EditorGUI.BeginChangeCheck();
if (Selection.activeGameObject != null) {
o = Selection.activeGameObject;
}
EditorGUILayout.ObjectField(o, typeof(GameObject), true);
EditorGUI.EndChangeCheck();
if (o != null) {
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Prefix:", GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.BeginHorizontal();
prefix = EditorGUILayout.TextField(prefix, GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Original Text:", GUILayout.Width(columnWidth));
GUILayout.Label("Replacement Text:", GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
originalText = EditorGUILayout.TextField(originalText, GUILayout.Width(columnWidth));
replacementText = EditorGUILayout.TextField(replacementText, GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
GUILayout.Label("Suffix:", GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
suffix = EditorGUILayout.TextField(suffix, GUILayout.Width(columnWidth));
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
EditorGUILayout.BeginHorizontal();
if (GUILayout.Button("Rename Icons and Text")) {
#if UNITY_EDITOR
Rename(o);
#endif
}
EditorGUILayout.EndHorizontal();
EditorGUILayout.Separator();
}
}
}
}

View File

@@ -0,0 +1,13 @@
fileFormatVersion: 2
guid: 6d2906bebe2d6024ba79f17fb908387f
timeCreated: 1516447032
licenseType: Free
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 3cac6d35505037446b512aea22d40688
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:

View File

@@ -0,0 +1,22 @@
{
"name": "UnityUIExtensions.editor",
"rootNamespace": "",
"references": [
"GUID:343deaaf83e0cee4ca978e7df0b80d21",
"GUID:2bafac87e7f4b9b418d9448d219b01ab",
"GUID:cf414061cae3a954baf92763590f3127",
"GUID:6055be8ebefd69e48b49212b09b47b2f",
"GUID:75469ad4d38634e559750d17036d5f7c"
],
"includePlatforms": [
"Editor"
],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": false,
"precompiledReferences": [],
"autoReferenced": true,
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}

View File

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

View File

@@ -0,0 +1,135 @@
/// Credit Senshi
/// Sourced from - http://forum.unity3d.com/threads/scripts-useful-4-6-scripts-collection.264161/ (uGUITools link)
using UnityEditor;
namespace UnityEngine.UI.Extensions
{
public static class uGUITools
{
[MenuItem("Tools/UnityUIExtensions/Anchors to Corners %[")]
static void AnchorsToCorners()
{
if (Selection.transforms == null || Selection.transforms.Length == 0)
{
return;
}
Undo.IncrementCurrentGroup();
Undo.SetCurrentGroupName("AnchorsToCorners");
var undoGroup = Undo.GetCurrentGroup();
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
Undo.RecordObject( t, "AnchorsToCorners" );
RectTransform pt = Selection.activeTransform.parent as RectTransform;
if (t == null || pt == null) return;
Vector2 newAnchorsMin = new Vector2(t.anchorMin.x + t.offsetMin.x / pt.rect.width,
t.anchorMin.y + t.offsetMin.y / pt.rect.height);
Vector2 newAnchorsMax = new Vector2(t.anchorMax.x + t.offsetMax.x / pt.rect.width,
t.anchorMax.y + t.offsetMax.y / pt.rect.height);
t.anchorMin = newAnchorsMin;
t.anchorMax = newAnchorsMax;
t.offsetMin = t.offsetMax = new Vector2(0, 0);
}
Undo.CollapseUndoOperations(undoGroup);
}
[MenuItem("Tools/UnityUIExtensions/Corners to Anchors %]")]
static void CornersToAnchors()
{
if (Selection.transforms == null || Selection.transforms.Length == 0)
{
return;
}
Undo.IncrementCurrentGroup();
Undo.SetCurrentGroupName("CornersToAnchors");
var undoGroup = Undo.GetCurrentGroup();
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
Undo.RecordObject( t, "CornersToAnchors" );
if (t == null) return;
t.offsetMin = t.offsetMax = new Vector2(0, 0);
}
Undo.CollapseUndoOperations(undoGroup);
}
[MenuItem("Tools/UnityUIExtensions/Mirror Horizontally Around Anchors %;")]
static void MirrorHorizontallyAnchors()
{
MirrorHorizontally(false);
}
[MenuItem("Tools/UnityUIExtensions/Mirror Horizontally Around Parent Center %:")]
static void MirrorHorizontallyParent()
{
MirrorHorizontally(true);
}
static void MirrorHorizontally(bool mirrorAnchors)
{
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
RectTransform pt = Selection.activeTransform.parent as RectTransform;
if (t == null || pt == null) return;
if (mirrorAnchors)
{
Vector2 oldAnchorMin = t.anchorMin;
t.anchorMin = new Vector2(1 - t.anchorMax.x, t.anchorMin.y);
t.anchorMax = new Vector2(1 - oldAnchorMin.x, t.anchorMax.y);
}
Vector2 oldOffsetMin = t.offsetMin;
t.offsetMin = new Vector2(-t.offsetMax.x, t.offsetMin.y);
t.offsetMax = new Vector2(-oldOffsetMin.x, t.offsetMax.y);
t.localScale = new Vector3(-t.localScale.x, t.localScale.y, t.localScale.z);
}
}
[MenuItem("Tools/UnityUIExtensions/Mirror Vertically Around Anchors %'")]
static void MirrorVerticallyAnchors()
{
MirrorVertically(false);
}
[MenuItem("Tools/UnityUIExtensions/Mirror Vertically Around Parent Center %\"")]
static void MirrorVerticallyParent()
{
MirrorVertically(true);
}
static void MirrorVertically(bool mirrorAnchors)
{
foreach (Transform transform in Selection.transforms)
{
RectTransform t = transform as RectTransform;
RectTransform pt = Selection.activeTransform.parent as RectTransform;
if (t == null || pt == null) return;
if (mirrorAnchors)
{
Vector2 oldAnchorMin = t.anchorMin;
t.anchorMin = new Vector2(t.anchorMin.x, 1 - t.anchorMax.y);
t.anchorMax = new Vector2(t.anchorMax.x, 1 - oldAnchorMin.y);
}
Vector2 oldOffsetMin = t.offsetMin;
t.offsetMin = new Vector2(t.offsetMin.x, -t.offsetMax.y);
t.offsetMax = new Vector2(t.offsetMax.x, -oldOffsetMin.y);
t.localScale = new Vector3(t.localScale.x, -t.localScale.y, t.localScale.z);
}
}
}
}

View File

@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: b896154a8dbdc524092e78923478d27a
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData: