8 [CustomEditor(typeof(CUIGraphic),
true)]
19 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);
23 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);
29 EditorGUILayout.HelpBox(
"Although CUI components are generalized. It is recommended that for Image, use CUIImage", MessageType.Warning);
33 EditorGUILayout.HelpBox(
"Although CUI components are generalized. It is recommended that for Text, use CUIText", MessageType.Warning);
36 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);
40 DrawDefaultInspector();
46 EditorGUI.indentLevel++;
47 EditorGUILayout.LabelField(
"Top Curve");
48 EditorGUI.indentLevel++;
51 EditorGUI.BeginChangeCheck();
52 for (
int p = 0; p < controlPoints.Length; p++)
54 reuse_Vector3s[p] = EditorGUILayout.Vector3Field(
string.Format(
"Control Points {0}", p + 1), controlPoints[p]);
57 if (EditorGUI.EndChangeCheck())
59 Undo.RecordObject(script,
"Change Ratio Points");
60 EditorUtility.SetDirty(script);
65 EditorGUI.indentLevel--;
66 EditorGUILayout.LabelField(
"Bottom Curve");
67 EditorGUI.indentLevel++;
70 EditorGUI.BeginChangeCheck();
71 for (
int p = 0; p < controlPoints.Length; p++)
73 reuse_Vector3s[p] = EditorGUILayout.Vector3Field(
string.Format(
"Control Points {0}", p + 1), controlPoints[p]);
76 if (EditorGUI.EndChangeCheck())
78 Undo.RecordObject(script,
"Change Ratio Points");
79 EditorUtility.SetDirty(script);
81 System.Array.Copy(
reuse_Vector3s, controlPoints, controlPoints.Length);
84 EditorGUI.indentLevel--;
85 EditorGUI.indentLevel--;
88 EditorGUILayout.Space();
89 if (GUILayout.Button(
"Fit Bezier curves to rect transform"))
91 Undo.RecordObject(script,
"Fit to Rect Transform");
92 Undo.RecordObject(script.
RefCurves[0],
"Fit to Rect Transform");
93 Undo.RecordObject(script.
RefCurves[1],
"Fit to Rect Transform");
94 EditorUtility.SetDirty(script);
101 EditorGUILayout.Space();
106 if (GUILayout.Button(
"Reference CUI component for curves"))
108 Undo.RecordObject(script,
"Reference CUI");
109 Undo.RecordObject(script.
RefCurves[0],
"Reference CUI");
110 Undo.RecordObject(script.
RefCurves[1],
"Reference CUI");
111 EditorUtility.SetDirty(script);
118 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);
120 EditorGUI.EndDisabledGroup();
131 for (
int c = 0; c < script.
RefCurves.Length; c++)
141 Transform handleTransform = curve.transform;
142 Quaternion handleRotation = curve.transform.rotation;
146 EditorGUI.BeginChangeCheck();
147 Handles.Label(handleTransform.TransformPoint(controlPoints[p]),
string.Format(
"Control Point {0}", p + 1));
148 Vector3 newPt = Handles.DoPositionHandle(handleTransform.TransformPoint(controlPoints[p]), handleRotation);
149 if (EditorGUI.EndChangeCheck())
152 Undo.RecordObject(curve,
"Move Point");
153 Undo.RecordObject(script,
"Move Point");
154 EditorUtility.SetDirty(curve);
155 controlPoints[p] = handleTransform.InverseTransformPoint(newPt);
160 Handles.color =
Color.gray;
161 Handles.DrawLine(handleTransform.TransformPoint(controlPoints[0]), handleTransform.TransformPoint(controlPoints[1]));
162 Handles.DrawLine(handleTransform.TransformPoint(controlPoints[1]), handleTransform.TransformPoint(controlPoints[2]));
163 Handles.DrawLine(handleTransform.TransformPoint(controlPoints[2]), handleTransform.TransformPoint(controlPoints[3]));
167 Handles.color =
Color.white;
168 for (
int s = 0; s < sampleSize; s++)
170 Handles.DrawLine(handleTransform.TransformPoint(curve.
GetPoint((
float)s / sampleSize)), handleTransform.TransformPoint(curve.
GetPoint((
float)(s + 1) / sampleSize)));
173 curve.EDITOR_ControlPoints = controlPoints;
System.Drawing.Image Image
Assume to be a cubic bezier curve at the moment.
static readonly int CubicBezierCurvePtNum
Vector3 GetPoint(float _time)
call this to get a sample
virtual void OnSceneGUI()
override void OnInspectorGUI()
static bool isCurveGpFold
virtual void ReportSet()
Check, prepare and set everything needed.
void ReferenceCUIForBCurves()
Vector3_Array2D[] RefCurvesControlRatioPoints
CUIBezierCurve[] RefCurves
void UpdateCurveControlPointPositions()
void FixTextToRectTrans()
Credit Erdener Gonenc - @PixelEnvision.