/************************************************************************************************************************/ private void DoBorderGUI() { var size = _Rect.rectValue.size; _BorderFields[0].normalizeMultiplier = _BorderFields[2].normalizeMultiplier = 1f / size.x; _BorderFields[1].normalizeMultiplier = _BorderFields[3].normalizeMultiplier = 1f / size.y; TwinFloatField.DoGroupGUI(_Border, AnimancerGUI.TempContent("Border", BorderTooltip), _BorderFields); }
/************************************************************************************************************************/ private void DoRectGUI() { var texture = ((Sprite)target).texture; _RectFields[0].normalizeMultiplier = _RectFields[2].normalizeMultiplier = 1f / texture.width; _RectFields[1].normalizeMultiplier = _RectFields[3].normalizeMultiplier = 1f / texture.height; TwinFloatField.DoGroupGUI(_Rect, AnimancerGUI.TempContent("Rect", RectTooltip), _RectFields); }
/************************************************************************************************************************/ private void OnEnable() { InitialisePreview(); _Name = serializedObject.FindProperty($"m{nameof(_Name)}"); _Rect = serializedObject.FindProperty($"m{nameof(_Rect)}"); if (_Rect != null) { _RectFields = new TwinFloatField[] { new TwinFloatField(_Rect.FindPropertyRelative(nameof(Rect.x)), new GUIContent("X (Left)", "The distance from the left edge of the texture to the left edge of the sprite"), false), new TwinFloatField(_Rect.FindPropertyRelative(nameof(Rect.y)), new GUIContent("Y (Bottom)", "The distance from the bottom edge of the texture to the bottom edge of the sprite"), false), new TwinFloatField(_Rect.FindPropertyRelative(nameof(Rect.width)), new GUIContent("Width", "The horizontal size of the sprite"), false), new TwinFloatField(_Rect.FindPropertyRelative(nameof(Rect.height)), new GUIContent("Height", "The vertical size of the sprite"), false), }; } _Pivot = serializedObject.FindProperty($"m{nameof(_Pivot)}"); if (_Pivot != null) { _PivotFields = new TwinFloatField[] { new TwinFloatField(_Pivot.FindPropertyRelative(nameof(Vector2.x)), new GUIContent("X", "The horizontal distance from the left edge of the sprite to the pivot point"), true), new TwinFloatField(_Pivot.FindPropertyRelative(nameof(Vector2.y)), new GUIContent("Y", "The vertical distance from the bottom edge of the sprite to the pivot point"), true), }; } _Border = serializedObject.FindProperty($"m{nameof(_Border)}"); if (_Border != null) { _BorderFields = new TwinFloatField[] { new TwinFloatField(_Border.FindPropertyRelative(nameof(Vector4.x)), new GUIContent("Left", BorderTooltip), false), new TwinFloatField(_Border.FindPropertyRelative(nameof(Vector4.y)), new GUIContent("Bottom", BorderTooltip), false), new TwinFloatField(_Border.FindPropertyRelative(nameof(Vector4.z)), new GUIContent("Right", BorderTooltip), false), new TwinFloatField(_Border.FindPropertyRelative(nameof(Vector4.w)), new GUIContent("Top", BorderTooltip), false), }; } }
/************************************************************************************************************************/ private void DoPivotGUI() { var showMixedValue = EditorGUI.showMixedValue; var targets = this.targets; var size = targets[0] is Sprite sprite ? sprite.rect.size : Vector2.one; for (int i = 1; i < targets.Length; i++) { sprite = targets[i] as Sprite; if (sprite == null || sprite.rect.size != size) { EditorGUI.showMixedValue = true; } } _PivotFields[0].normalizeMultiplier = 1f / size.x; _PivotFields[1].normalizeMultiplier = 1f / size.y; TwinFloatField.DoGroupGUI(_Pivot, AnimancerGUI.TempContent("Pivot", PivotTooltip), _PivotFields); EditorGUI.showMixedValue = showMixedValue; }