first commit

This commit is contained in:
SimonSayeBabu
2025-01-17 13:10:20 +01:00
commit bd1057cec0
16967 changed files with 1048699 additions and 0 deletions

View File

@@ -0,0 +1,69 @@
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
namespace UnityEditor.UI
{
[CustomPropertyDrawer(typeof(AnimationTriggers), true)]
/// <summary>
/// This is a PropertyDrawer for AnimationTriggers. It is implemented using the standard Unity PropertyDrawer framework.
/// </summary>
public class AnimationTriggersDrawer : PropertyDrawer
{
const string kNormalTrigger = "m_NormalTrigger";
const string kHighlightedTrigger = "m_HighlightedTrigger";
const string kPressedTrigger = "m_PressedTrigger";
const string kSelectedTrigger = "m_SelectedTrigger";
const string kDisabledTrigger = "m_DisabledTrigger";
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect drawRect = rect;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty normalTrigger = prop.FindPropertyRelative(kNormalTrigger);
SerializedProperty higlightedTrigger = prop.FindPropertyRelative(kHighlightedTrigger);
SerializedProperty pressedTrigger = prop.FindPropertyRelative(kPressedTrigger);
SerializedProperty selectedTrigger = prop.FindPropertyRelative(kSelectedTrigger);
SerializedProperty disabledTrigger = prop.FindPropertyRelative(kDisabledTrigger);
EditorGUI.PropertyField(drawRect, normalTrigger);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, higlightedTrigger);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedTrigger);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectedTrigger);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledTrigger);
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 5 * EditorGUIUtility.singleLineHeight + 4 * EditorGUIUtility.standardVerticalSpacing;
}
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var container = new VisualElement();
var properties = new[]
{
property.FindPropertyRelative(kNormalTrigger),
property.FindPropertyRelative(kHighlightedTrigger),
property.FindPropertyRelative(kPressedTrigger),
property.FindPropertyRelative(kSelectedTrigger),
property.FindPropertyRelative(kDisabledTrigger),
};
foreach (var prop in properties)
{
var field = new PropertyField(prop);
container.Add(field);
}
return container;
}
}
}

View File

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

View File

@@ -0,0 +1,79 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.UI
{
[CustomPropertyDrawer(typeof(ColorBlock), true)]
/// <summary>
/// This is a PropertyDrawer for ColorBlock. It is implemented using the standard Unity PropertyDrawer framework..
/// </summary>
public class ColorBlockDrawer : PropertyDrawer
{
const string kNormalColor = "m_NormalColor";
const string kHighlightedColor = "m_HighlightedColor";
const string kPressedColor = "m_PressedColor";
const string kSelectedColor = "m_SelectedColor";
const string kDisabledColor = "m_DisabledColor";
const string kColorMultiplier = "m_ColorMultiplier";
const string kFadeDuration = "m_FadeDuration";
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect drawRect = rect;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty normalColor = prop.FindPropertyRelative(kNormalColor);
SerializedProperty highlighted = prop.FindPropertyRelative(kHighlightedColor);
SerializedProperty pressedColor = prop.FindPropertyRelative(kPressedColor);
SerializedProperty selectedColor = prop.FindPropertyRelative(kSelectedColor);
SerializedProperty disabledColor = prop.FindPropertyRelative(kDisabledColor);
SerializedProperty colorMultiplier = prop.FindPropertyRelative(kColorMultiplier);
SerializedProperty fadeDuration = prop.FindPropertyRelative(kFadeDuration);
EditorGUI.PropertyField(drawRect, normalColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, highlighted);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectedColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledColor);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, colorMultiplier);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, fadeDuration);
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 7 * EditorGUIUtility.singleLineHeight + 6 * EditorGUIUtility.standardVerticalSpacing;
}
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
VisualElement container = new VisualElement();
var properties = new[]
{
property.FindPropertyRelative(kNormalColor),
property.FindPropertyRelative(kHighlightedColor),
property.FindPropertyRelative(kPressedColor),
property.FindPropertyRelative(kSelectedColor),
property.FindPropertyRelative(kDisabledColor),
property.FindPropertyRelative(kColorMultiplier),
property.FindPropertyRelative(kFadeDuration)
};
foreach (var prop in properties)
{
var field = new PropertyField(prop);
container.Add(field);
}
return container;
}
}
}

View File

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

View File

@@ -0,0 +1,121 @@
using System;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
using UnityEditor;
using UnityEditor.UIElements;
namespace UnityEditor.UI
{
[CustomPropertyDrawer(typeof(Dropdown.OptionDataList), true)]
/// <summary>
/// This is a PropertyDrawer for Dropdown.OptionDataList. It is implemented using the standard Unity PropertyDrawer framework.
/// </summary>
class DropdownOptionListDrawer : PropertyDrawer
{
const string kOptionsPath = "m_Options";
const string kTextPath = "m_Text";
const string kImagePath = "m_Image";
const string kHeader = "Options";
const string kListViewUssName = "unity-list-view__header";
const string kVisualElementName = "DropdownOptionDataList";
// Offset for fixed size list items, so it wouldn't look tight or overlap each other
const float itemOffset = 4;
private ReorderableList m_ReorderableList;
private void Init(SerializedProperty property)
{
if (m_ReorderableList != null && m_ReorderableList.serializedProperty.serializedObject.m_NativeObjectPtr != IntPtr.Zero)
{
return;
}
SerializedProperty array = property.FindPropertyRelative(kOptionsPath);
m_ReorderableList = new ReorderableList(property.serializedObject, array);
m_ReorderableList.drawElementCallback = DrawOptionData;
m_ReorderableList.drawHeaderCallback = DrawHeader;
m_ReorderableList.elementHeight += 16;
}
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
Init(property);
m_ReorderableList.DoList(position);
}
private void DrawHeader(Rect rect)
{
GUI.Label(rect, kHeader);
}
private void DrawOptionData(Rect rect, int index, bool isActive, bool isFocused)
{
SerializedProperty itemData = m_ReorderableList.serializedProperty.GetArrayElementAtIndex(index);
SerializedProperty itemText = itemData.FindPropertyRelative(kTextPath);
SerializedProperty itemImage = itemData.FindPropertyRelative(kImagePath);
RectOffset offset = new RectOffset(0, 0, -1, -3);
rect = offset.Add(rect);
rect.height = EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, itemText, GUIContent.none);
rect.y += EditorGUIUtility.singleLineHeight;
EditorGUI.PropertyField(rect, itemImage, GUIContent.none);
}
public override float GetPropertyHeight(SerializedProperty property, GUIContent label)
{
Init(property);
return m_ReorderableList.GetHeight();
}
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var root = new VisualElement();
root.name = kVisualElementName;
Init(property);
var headerElement = new VisualElement();
headerElement.AddToClassList(kListViewUssName);
var header = new Label(kHeader);
headerElement.Add(header);
root.Add(headerElement);
var listView = CreateListView(property);
root.Add(listView);
return root;
}
ListView CreateListView(SerializedProperty property)
{
var listView = new ListView
{
showAddRemoveFooter = true,
reorderMode = ListViewReorderMode.Animated,
showBorder = true,
showFoldoutHeader = false,
showBoundCollectionSize = false,
showAlternatingRowBackgrounds = AlternatingRowBackground.None,
fixedItemHeight = m_ReorderableList.elementHeight + itemOffset,
horizontalScrollingEnabled = false,
name = kHeader
};
var propertyRelative = property.FindPropertyRelative(kOptionsPath);
listView.bindingPath = propertyRelative.propertyPath;
listView.makeItem += () => new DropdownOptionListItem(kTextPath, kImagePath);
return listView;
}
}
}

View File

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

View File

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

View File

@@ -0,0 +1,152 @@
using System;
using UnityEditor.UIElements;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.UIElements;
namespace UnityEditor.UI
{
[CustomPropertyDrawer(typeof(Navigation), true)]
/// <summary>
/// This is a PropertyDrawer for Navigation. It is implemented using the standard Unity PropertyDrawer framework.
/// </summary>
public class NavigationDrawer : PropertyDrawer
{
const string kNavigation = "Navigation";
const string kModeProp = "m_Mode";
const string kWrapAroundProp = "m_WrapAround";
const string kSelectOnUpProp = "m_SelectOnUp";
const string kSelectOnDownProp = "m_SelectOnDown";
const string kSelectOnLeftProp = "m_SelectOnLeft";
const string kSelectOnRightProp = "m_SelectOnRight";
const string kHiddenClass = "unity-ui-navigation-hidden";
private class Styles
{
readonly public GUIContent navigationContent;
public Styles()
{
navigationContent = EditorGUIUtility.TrTextContent(kNavigation);
}
}
private static Styles s_Styles = null;
public override void OnGUI(Rect pos, SerializedProperty prop, GUIContent label)
{
if (s_Styles == null)
s_Styles = new Styles();
Rect drawRect = pos;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty navigation = prop.FindPropertyRelative(kModeProp);
SerializedProperty wrapAround = prop.FindPropertyRelative(kWrapAroundProp);
Navigation.Mode navMode = GetNavigationMode(navigation);
EditorGUI.PropertyField(drawRect, navigation, s_Styles.navigationContent);
++EditorGUI.indentLevel;
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
switch (navMode)
{
case Navigation.Mode.Horizontal:
case Navigation.Mode.Vertical:
{
EditorGUI.PropertyField(drawRect, wrapAround);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
break;
case Navigation.Mode.Explicit:
{
SerializedProperty selectOnUp = prop.FindPropertyRelative(kSelectOnUpProp);
SerializedProperty selectOnDown = prop.FindPropertyRelative(kSelectOnDownProp);
SerializedProperty selectOnLeft = prop.FindPropertyRelative(kSelectOnLeftProp);
SerializedProperty selectOnRight = prop.FindPropertyRelative(kSelectOnRightProp);
EditorGUI.PropertyField(drawRect, selectOnUp);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectOnDown);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectOnLeft);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectOnRight);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
break;
}
--EditorGUI.indentLevel;
}
static Navigation.Mode GetNavigationMode(SerializedProperty navigation)
{
return (Navigation.Mode)navigation.enumValueIndex;
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
SerializedProperty navigation = prop.FindPropertyRelative(kModeProp);
if (navigation == null)
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
Navigation.Mode navMode = GetNavigationMode(navigation);
switch (navMode)
{
case Navigation.Mode.None:
return EditorGUIUtility.singleLineHeight;
case Navigation.Mode.Horizontal:
case Navigation.Mode.Vertical:
return 2 * EditorGUIUtility.singleLineHeight + 2 * EditorGUIUtility.standardVerticalSpacing;
case Navigation.Mode.Explicit:
return 5 * EditorGUIUtility.singleLineHeight + 5 * EditorGUIUtility.standardVerticalSpacing;
default:
return EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
}
PropertyField PrepareField(VisualElement parent, string propertyPath, bool hideable = true, string label = null)
{
var field = new PropertyField(null, label) { bindingPath = propertyPath };
if (hideable) field.AddToClassList(kHiddenClass);
parent.Add(field);
return field;
}
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var container = new VisualElement() { name = kNavigation };
var indented = new VisualElement() { name = "Indent" };
indented.AddToClassList("unity-ui-navigation-indent");
var navigation = PrepareField(container, kModeProp, false, kNavigation);
var wrapAround = PrepareField(indented, kWrapAroundProp);
var selectOnUp = PrepareField(indented, kSelectOnUpProp);
var selectOnDown = PrepareField(indented, kSelectOnDownProp);
var selectOnLeft = PrepareField(indented, kSelectOnLeftProp);
var selectOnRight = PrepareField(indented, kSelectOnRightProp);
Action<Navigation.Mode> callback = (value) =>
{
wrapAround.EnableInClassList(kHiddenClass, value != Navigation.Mode.Vertical && value != Navigation.Mode.Horizontal);
selectOnUp.EnableInClassList(kHiddenClass, value != Navigation.Mode.Explicit);
selectOnDown.EnableInClassList(kHiddenClass, value != Navigation.Mode.Explicit);
selectOnLeft.EnableInClassList(kHiddenClass, value != Navigation.Mode.Explicit);
selectOnRight.EnableInClassList(kHiddenClass, value != Navigation.Mode.Explicit);
};
navigation.RegisterValueChangeCallback((e) => callback.Invoke((Navigation.Mode)e.changedProperty.enumValueIndex));
callback.Invoke((Navigation.Mode)property.FindPropertyRelative(kModeProp).enumValueFlag);
container.Add(indented);
return container;
}
}
}

View File

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

View File

@@ -0,0 +1,65 @@
using UnityEngine;
using UnityEngine.UI;
using UnityEditor.UIElements;
using UnityEngine.UIElements;
namespace UnityEditor.UI
{
[CustomPropertyDrawer(typeof(SpriteState), true)]
/// <summary>
/// This is a PropertyDrawer for SpriteState. It is implemented using the standard Unity PropertyDrawer framework.
/// </summary>
public class SpriteStateDrawer : PropertyDrawer
{
const string kHighlightedSprite = "m_HighlightedSprite";
const string kPressedSprite = "m_PressedSprite";
const string kSelectedSprite = "m_SelectedSprite";
const string kDisabledSprite = "m_DisabledSprite";
const string kVisualElementName = "SpriteState";
public override void OnGUI(Rect rect, SerializedProperty prop, GUIContent label)
{
Rect drawRect = rect;
drawRect.height = EditorGUIUtility.singleLineHeight;
SerializedProperty highlightedSprite = prop.FindPropertyRelative(kHighlightedSprite);
SerializedProperty pressedSprite = prop.FindPropertyRelative(kPressedSprite);
SerializedProperty selectedSprite = prop.FindPropertyRelative(kSelectedSprite);
SerializedProperty disabledSprite = prop.FindPropertyRelative(kDisabledSprite);
EditorGUI.PropertyField(drawRect, highlightedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, pressedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, selectedSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
EditorGUI.PropertyField(drawRect, disabledSprite);
drawRect.y += EditorGUIUtility.singleLineHeight + EditorGUIUtility.standardVerticalSpacing;
}
public override float GetPropertyHeight(SerializedProperty prop, GUIContent label)
{
return 4 * EditorGUIUtility.singleLineHeight + 3 * EditorGUIUtility.standardVerticalSpacing;
}
public override VisualElement CreatePropertyGUI(SerializedProperty property)
{
var container = new VisualElement();
container.name = kVisualElementName;
var properties = new[]
{
property.FindPropertyRelative(kHighlightedSprite),
property.FindPropertyRelative(kPressedSprite),
property.FindPropertyRelative(kSelectedSprite),
property.FindPropertyRelative(kDisabledSprite)
};
foreach (var prop in properties)
{
container.Add(new PropertyField(prop));
}
return container;
}
}
}

View File

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