2023-01-22 16:38:23 +01:00
|
|
|
using ABI.CCK.Components;
|
|
|
|
using UnityEditor;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace ABI.CCK.Scripts.Editor
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
[CanEditMultipleObjects]
|
|
|
|
[CustomEditor(typeof(CVRAssetInfo))]
|
2023-01-22 16:38:23 +01:00
|
|
|
public class CCK_CVRAssetInfoEditor : UnityEditor.Editor
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
private SerializedProperty _objectIdProperty;
|
|
|
|
|
|
|
|
private string _newGUID;
|
|
|
|
|
|
|
|
#region Unity Events
|
|
|
|
|
|
|
|
private void OnEnable()
|
|
|
|
{
|
|
|
|
if (target == null)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_objectIdProperty = serializedObject.FindProperty("objectId");
|
|
|
|
}
|
2023-01-22 16:38:23 +01:00
|
|
|
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
serializedObject.Update();
|
|
|
|
|
|
|
|
DrawHeaderInfo();
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(_objectIdProperty.stringValue))
|
|
|
|
DrawDetachGUID();
|
|
|
|
else
|
|
|
|
DrawAttachGUID();
|
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#region GUI Drawing
|
|
|
|
|
|
|
|
private void DrawHeaderInfo()
|
|
|
|
{
|
2023-01-22 16:38:23 +01:00
|
|
|
EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_HEADER_INFORMATION"), MessageType.Info);
|
2024-08-03 22:24:42 +02:00
|
|
|
}
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
private void DrawDetachGUID()
|
|
|
|
{
|
|
|
|
EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_GUID_LABEL") + _objectIdProperty.stringValue, MessageType.Info);
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
EditorGUILayout.BeginHorizontal();
|
|
|
|
|
|
|
|
if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_DETACH_BUTTON")))
|
|
|
|
{
|
|
|
|
bool shouldDetach = EditorUtility.DisplayDialog(
|
|
|
|
CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_DETACH_BUTTON_DIALOG_TITLE"),
|
|
|
|
CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_DETACH_BUTTON_DIALOG_BODY"),
|
|
|
|
CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_DETACH_BUTTON_DIALOG_ACCEPT"),
|
|
|
|
CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_DETACH_BUTTON_DIALOG_DENY"));
|
2023-01-22 16:38:23 +01:00
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
if (shouldDetach)
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
_newGUID = _objectIdProperty.stringValue;
|
|
|
|
_objectIdProperty.stringValue = string.Empty;
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
if (GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_COPY_BUTTON")))
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
if (!string.IsNullOrEmpty(_objectIdProperty.stringValue))
|
|
|
|
GUIUtility.systemCopyBuffer = _objectIdProperty.stringValue;
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
EditorGUILayout.EndHorizontal();
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
|
|
|
|
private void DrawAttachGUID()
|
2023-01-22 16:38:23 +01:00
|
|
|
{
|
2024-08-03 22:24:42 +02:00
|
|
|
_newGUID = EditorGUILayout.TextField(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_ATTACH_LABEL"), _newGUID);
|
|
|
|
EditorGUILayout.HelpBox(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_ATTACH_INFO"), MessageType.Warning);
|
|
|
|
|
|
|
|
if (!GUILayout.Button(CCKLocalizationProvider.GetLocalizedText("ABI_UI_ASSET_INFO_ATTACH_BUTTON")))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (System.Guid.TryParse(_newGUID, out _))
|
|
|
|
_objectIdProperty.stringValue = _newGUID;
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
|
|
|
|
2024-08-03 22:24:42 +02:00
|
|
|
#endregion
|
2023-01-22 16:38:23 +01:00
|
|
|
}
|
2024-08-03 22:24:42 +02:00
|
|
|
}
|