|
|
|
|
|
using UnityEditor;
|
|
|
|
|
|
using UnityEditorInternal;
|
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
|
|
|
|
namespace uc
|
|
|
|
|
|
{
|
|
|
|
|
|
[CanEditMultipleObjects, CustomEditor(typeof(CanvasActivity), false)]
|
|
|
|
|
|
public class CanvasActivityEditor : ActivityBaseEditor
|
|
|
|
|
|
{
|
|
|
|
|
|
SerializedProperty m_FadeTimeProperty;
|
|
|
|
|
|
GUIContent m_FadeTimeLabel;
|
|
|
|
|
|
SerializedProperty m_FadeOutTimeProperty;
|
|
|
|
|
|
|
|
|
|
|
|
SerializedProperty m_TouchDelayProperty;
|
|
|
|
|
|
GUIContent m_TouchDelayLabel;
|
|
|
|
|
|
|
|
|
|
|
|
SerializedProperty m_GlobalItemsProperty;
|
|
|
|
|
|
ReorderableList m_GlobalItemsList;
|
|
|
|
|
|
|
|
|
|
|
|
CanvasActivity canvas_activity;
|
|
|
|
|
|
|
|
|
|
|
|
protected override void OnEnable()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.OnEnable();
|
|
|
|
|
|
|
|
|
|
|
|
canvas_activity = target as CanvasActivity;
|
|
|
|
|
|
|
|
|
|
|
|
m_FadeTimeProperty = serializedObject.FindProperty("fadeTime");
|
|
|
|
|
|
m_FadeTimeLabel = new GUIContent("Fading Time", "time to fade canvas (second)");
|
|
|
|
|
|
|
|
|
|
|
|
m_FadeOutTimeProperty = serializedObject.FindProperty("fadeOutTime");
|
|
|
|
|
|
|
|
|
|
|
|
m_TouchDelayProperty = serializedObject.FindProperty("touchDelayTime");
|
|
|
|
|
|
m_TouchDelayLabel = new GUIContent("Delay Time", "delay time to interactable");
|
|
|
|
|
|
|
|
|
|
|
|
m_GlobalItemsProperty = serializedObject.FindProperty("sharedComponents");
|
|
|
|
|
|
m_GlobalItemsList = new ReorderableList(serializedObject, m_GlobalItemsProperty, true, true, true, true);
|
|
|
|
|
|
m_GlobalItemsList.drawHeaderCallback = rect =>
|
|
|
|
|
|
{
|
|
|
|
|
|
EditorGUI.LabelField(rect, "Shared Components");
|
|
|
|
|
|
};
|
|
|
|
|
|
m_GlobalItemsList.drawElementCallback = (rect, index, active, focused) =>
|
|
|
|
|
|
{
|
|
|
|
|
|
SerializedProperty prefab = m_GlobalItemsProperty.GetArrayElementAtIndex(index);
|
|
|
|
|
|
RectTransform go = (RectTransform)prefab.objectReferenceValue;
|
|
|
|
|
|
|
|
|
|
|
|
GUIContent label;
|
|
|
|
|
|
if (go == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
label = new GUIContent("Empty", "Drag a GameObject here");
|
|
|
|
|
|
}
|
|
|
|
|
|
else
|
|
|
|
|
|
{
|
|
|
|
|
|
label = new GUIContent(go.name);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float shrink = 0.2f;
|
|
|
|
|
|
rect.y += rect.height * shrink * 0.4f;
|
|
|
|
|
|
rect.height *= (1.0f - shrink);
|
|
|
|
|
|
|
|
|
|
|
|
var newGameObject = (RectTransform)EditorGUI.ObjectField(rect, label, go, typeof(RectTransform), true);
|
|
|
|
|
|
if (newGameObject == null)
|
|
|
|
|
|
{
|
|
|
|
|
|
canvas_activity.sharedComponents[index] = null;
|
|
|
|
|
|
EditorUtility.SetDirty(target);
|
|
|
|
|
|
return;
|
|
|
|
|
|
}
|
|
|
|
|
|
if (canvas_activity.sharedComponents[index] != newGameObject)
|
|
|
|
|
|
{
|
|
|
|
|
|
canvas_activity.sharedComponents[index] = newGameObject;
|
|
|
|
|
|
EditorUtility.SetDirty(target);
|
|
|
|
|
|
}
|
|
|
|
|
|
};
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public override void OnInspectorGUI()
|
|
|
|
|
|
{
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
serializedObject.Update();
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.PropertyField(m_FadeTimeProperty, m_FadeTimeLabel);
|
|
|
|
|
|
EditorGUILayout.PropertyField(m_FadeOutTimeProperty);
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.PropertyField(m_TouchDelayProperty, m_TouchDelayLabel);
|
|
|
|
|
|
|
|
|
|
|
|
EditorGUILayout.Space();
|
|
|
|
|
|
m_GlobalItemsList.DoLayoutList();
|
|
|
|
|
|
|
|
|
|
|
|
serializedObject.ApplyModifiedProperties();
|
|
|
|
|
|
|
|
|
|
|
|
DrawEventInspectorGUI();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|