Initial Commit
This commit is contained in:
parent
53eb92e9af
commit
270ab7d11f
15341 changed files with 700234 additions and 0 deletions
|
@ -0,0 +1,71 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEditor.EventSystems
|
||||
{
|
||||
[CustomEditor(typeof(EventSystem), true)]
|
||||
/// <summary>
|
||||
/// Custom Editor for the EventSystem Component.
|
||||
/// Extend this class to write a custom editor for a component derived from EventSystem.
|
||||
/// </summary>
|
||||
public class EventSystemEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
DrawDefaultInspector();
|
||||
|
||||
var eventSystem = target as EventSystem;
|
||||
if (eventSystem == null)
|
||||
return;
|
||||
|
||||
if (eventSystem.GetComponent<BaseInputModule>() != null)
|
||||
return;
|
||||
|
||||
// no input modules :(
|
||||
if (GUILayout.Button("Add Default Input Modules"))
|
||||
{
|
||||
ObjectFactory.AddComponent<StandaloneInputModule>(eventSystem.gameObject);
|
||||
Undo.RegisterCreatedObjectUndo(eventSystem.gameObject, "Add StandaloneInputModule");
|
||||
}
|
||||
}
|
||||
|
||||
public override bool HasPreviewGUI()
|
||||
{
|
||||
return Application.isPlaying;
|
||||
}
|
||||
|
||||
private GUIStyle m_PreviewLabelStyle;
|
||||
|
||||
protected GUIStyle previewLabelStyle
|
||||
{
|
||||
get
|
||||
{
|
||||
if (m_PreviewLabelStyle == null)
|
||||
{
|
||||
m_PreviewLabelStyle = new GUIStyle("PreOverlayLabel")
|
||||
{
|
||||
richText = true,
|
||||
alignment = TextAnchor.UpperLeft,
|
||||
fontStyle = FontStyle.Normal
|
||||
};
|
||||
}
|
||||
|
||||
return m_PreviewLabelStyle;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool RequiresConstantRepaint()
|
||||
{
|
||||
return Application.isPlaying;
|
||||
}
|
||||
|
||||
public override void OnPreviewGUI(Rect rect, GUIStyle background)
|
||||
{
|
||||
var system = target as EventSystem;
|
||||
if (system == null)
|
||||
return;
|
||||
|
||||
GUI.Label(rect, system.ToString(), previewLabelStyle);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6f72aa6eab9392548b9e9d92eb6b2ef8
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,122 @@
|
|||
using System;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEditor.EventSystems
|
||||
{
|
||||
[CustomEditor(typeof(EventTrigger), true)]
|
||||
public class EventTriggerEditor : Editor
|
||||
{
|
||||
SerializedProperty m_DelegatesProperty;
|
||||
|
||||
GUIContent m_IconToolbarMinus;
|
||||
GUIContent m_EventIDName;
|
||||
GUIContent[] m_EventTypes;
|
||||
GUIContent m_AddButonContent;
|
||||
|
||||
protected virtual void OnEnable()
|
||||
{
|
||||
m_DelegatesProperty = serializedObject.FindProperty("m_Delegates");
|
||||
m_AddButonContent = EditorGUIUtility.TrTextContent("Add New Event Type");
|
||||
m_EventIDName = new GUIContent("");
|
||||
// Have to create a copy since otherwise the tooltip will be overwritten.
|
||||
m_IconToolbarMinus = new GUIContent(EditorGUIUtility.IconContent("Toolbar Minus"));
|
||||
m_IconToolbarMinus.tooltip = "Remove all events in this list.";
|
||||
|
||||
string[] eventNames = Enum.GetNames(typeof(EventTriggerType));
|
||||
m_EventTypes = new GUIContent[eventNames.Length];
|
||||
for (int i = 0; i < eventNames.Length; ++i)
|
||||
{
|
||||
m_EventTypes[i] = new GUIContent(eventNames[i]);
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
serializedObject.Update();
|
||||
int toBeRemovedEntry = -1;
|
||||
|
||||
EditorGUILayout.Space();
|
||||
|
||||
Vector2 removeButtonSize = GUIStyle.none.CalcSize(m_IconToolbarMinus);
|
||||
|
||||
for (int i = 0; i < m_DelegatesProperty.arraySize; ++i)
|
||||
{
|
||||
SerializedProperty delegateProperty = m_DelegatesProperty.GetArrayElementAtIndex(i);
|
||||
SerializedProperty eventProperty = delegateProperty.FindPropertyRelative("eventID");
|
||||
SerializedProperty callbacksProperty = delegateProperty.FindPropertyRelative("callback");
|
||||
m_EventIDName.text = eventProperty.enumDisplayNames[eventProperty.enumValueIndex];
|
||||
|
||||
EditorGUILayout.PropertyField(callbacksProperty, m_EventIDName);
|
||||
Rect callbackRect = GUILayoutUtility.GetLastRect();
|
||||
|
||||
Rect removeButtonPos = new Rect(callbackRect.xMax - removeButtonSize.x - 8, callbackRect.y + 1, removeButtonSize.x, removeButtonSize.y);
|
||||
if (GUI.Button(removeButtonPos, m_IconToolbarMinus, GUIStyle.none))
|
||||
{
|
||||
toBeRemovedEntry = i;
|
||||
}
|
||||
|
||||
EditorGUILayout.Space();
|
||||
}
|
||||
|
||||
if (toBeRemovedEntry > -1)
|
||||
{
|
||||
RemoveEntry(toBeRemovedEntry);
|
||||
}
|
||||
|
||||
Rect btPosition = GUILayoutUtility.GetRect(m_AddButonContent, GUI.skin.button);
|
||||
const float addButonWidth = 200f;
|
||||
btPosition.x = btPosition.x + (btPosition.width - addButonWidth) / 2;
|
||||
btPosition.width = addButonWidth;
|
||||
if (GUI.Button(btPosition, m_AddButonContent))
|
||||
{
|
||||
ShowAddTriggermenu();
|
||||
}
|
||||
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
|
||||
private void RemoveEntry(int toBeRemovedEntry)
|
||||
{
|
||||
m_DelegatesProperty.DeleteArrayElementAtIndex(toBeRemovedEntry);
|
||||
}
|
||||
|
||||
void ShowAddTriggermenu()
|
||||
{
|
||||
// Now create the menu, add items and show it
|
||||
GenericMenu menu = new GenericMenu();
|
||||
for (int i = 0; i < m_EventTypes.Length; ++i)
|
||||
{
|
||||
bool active = true;
|
||||
|
||||
// Check if we already have a Entry for the current eventType, if so, disable it
|
||||
for (int p = 0; p < m_DelegatesProperty.arraySize; ++p)
|
||||
{
|
||||
SerializedProperty delegateEntry = m_DelegatesProperty.GetArrayElementAtIndex(p);
|
||||
SerializedProperty eventProperty = delegateEntry.FindPropertyRelative("eventID");
|
||||
if (eventProperty.enumValueIndex == i)
|
||||
{
|
||||
active = false;
|
||||
}
|
||||
}
|
||||
if (active)
|
||||
menu.AddItem(m_EventTypes[i], false, OnAddNewSelected, i);
|
||||
else
|
||||
menu.AddDisabledItem(m_EventTypes[i]);
|
||||
}
|
||||
menu.ShowAsContext();
|
||||
Event.current.Use();
|
||||
}
|
||||
|
||||
private void OnAddNewSelected(object index)
|
||||
{
|
||||
int selected = (int)index;
|
||||
|
||||
m_DelegatesProperty.arraySize += 1;
|
||||
SerializedProperty delegateEntry = m_DelegatesProperty.GetArrayElementAtIndex(m_DelegatesProperty.arraySize - 1);
|
||||
SerializedProperty eventProperty = delegateEntry.FindPropertyRelative("eventID");
|
||||
eventProperty.enumValueIndex = selected;
|
||||
serializedObject.ApplyModifiedProperties();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 37b164a494cd92a498526852ecceedef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,21 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEditor.EventSystems
|
||||
{
|
||||
[CustomEditor(typeof(Physics2DRaycaster), true)]
|
||||
/// <summary>
|
||||
/// Custom Editor for the EventSystem Component.
|
||||
/// Extend this class to write a custom editor for a component derived from EventSystem.
|
||||
/// </summary>
|
||||
public class Physics2DRaycasterEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
#if !PACKAGE_PHYSICS2D
|
||||
EditorGUILayout.HelpBox("Physics2D module is not present. This Raycaster will have no effect", MessageType.Warning);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1143ae6bb91836f4a8f8ebfaabb9396d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -0,0 +1,20 @@
|
|||
using UnityEngine.EventSystems;
|
||||
|
||||
namespace UnityEditor.EventSystems
|
||||
{
|
||||
[CustomEditor(typeof(PhysicsRaycaster), true)]
|
||||
/// <summary>
|
||||
/// Custom Editor for the EventSystem Component.
|
||||
/// Extend this class to write a custom editor for a component derived from EventSystem.
|
||||
/// </summary>
|
||||
public class PhysicsRaycasterEditor : Editor
|
||||
{
|
||||
public override void OnInspectorGUI()
|
||||
{
|
||||
base.OnInspectorGUI();
|
||||
#if !PACKAGE_PHYSICS
|
||||
EditorGUILayout.HelpBox("Physics module is not present. This Raycaster will have no effect", MessageType.Warning);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e976a5e755c7016418f66e15223c1b90
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue