Firstborn/Library/PackageCache/com.unity.addressables@1.19.19/Editor/GUI/AssetLabelReferenceDrawer.cs
Schaken-Mods 7502018d20 Adding Mod Support
There is an asset in the store I grabbed. the coding is WAY above my head, I got about half of it and integrated and adapted what I can to it. im going as far as I can with it and ill come back in a few month when I understand t better.
2023-05-13 22:01:48 -05:00

35 lines
1.3 KiB
C#

using System;
using UnityEngine;
using UnityEngine.AddressableAssets;
namespace UnityEditor.AddressableAssets.GUI
{
[CustomPropertyDrawer(typeof(AssetLabelReference), true)]
class AssetLabelReferenceDrawer : PropertyDrawer
{
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
{
EditorGUI.BeginProperty(position, label, property);
var currentLabel = property.FindPropertyRelative("m_LabelString");
var smallPos = EditorGUI.PrefixLabel(position, label);
if (AddressableAssetSettingsDefaultObject.Settings == null)
{
using (new EditorGUI.DisabledScope(true))
EditorGUI.LabelField(smallPos, new GUIContent(currentLabel.stringValue));
}
else
{
var labelList = AddressableAssetSettingsDefaultObject.Settings.labelTable.labelNames.ToArray();
var currIndex = Array.IndexOf(labelList, currentLabel.stringValue);
var newIndex = EditorGUI.Popup(smallPos, currIndex, labelList);
if (newIndex != currIndex)
{
currentLabel.stringValue = labelList[newIndex];
}
}
EditorGUI.EndProperty();
}
}
}