Files
Magical-Jumping-Bean/Library/metadata/12/127023922adddf744b59fa7b0b0c3030
T

277 lines
16 KiB
Plaintext
Raw Normal View History

2019-09-29 19:40:54 -04:00
í?2019.2.3f1þÿÿÿÿÿ’3$øÌuñ옲e+ Í=^7€ÿÿÿÿ¦€²Ð¦¦¦€#¦€+H€3ÿÿÿÿ1€1€ÿÿÿÿ@Þ Q€j
H€<ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jÕ€Iÿÿÿÿ1€1€ÿÿÿÿÀÞH€j€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€j€PAssetMetaDataguiddata[0]data[1]data[2]data[3]pathNameoriginalNamelabelsassetStoreRef ÿÿfš†!ë5˜9Ý4QÁóBí7€ÿÿÿÿ¦€²
E Þ€#.€,5a Þ€#.€,€r Þ€# .€,
H€«€ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jñ€JÿÿÿÿÀ1€1€ÿÿÿÿÞ€j€ÿÿÿÿ\€ÿÿÿÿH€rÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jH€wÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jH€€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jy
 Þ€#!.€,"€…ÿÿÿÿ#@1€1€ÿÿÿÿ$Þ%.€j&Õ€“ÿÿÿÿ'1€1€ÿÿÿÿ(ÀÞ)€j€ÿÿÿÿ*H€›€ÿÿÿÿ+1€1€ÿÿÿÿ,@Þ-Q€j.y
 /Þ€#0.€,1 €§2@¾€¶ 3@Þ€#4.€,5H€»ÿÿÿÿ61€1€ÿÿÿÿ7@Þ8Q€j9H€Æÿÿÿÿ:1€1€ÿÿÿÿ;@Þ<Q€j=H€Øÿÿÿÿ>1€1€ÿÿÿÿ?@Þ@Q€jAMonoImporterPPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_ExternalObjectsSourceAssetIdentifiertypeassemblynamem_UsedFileIDsm_DefaultReferencesexecutionOrdericonm_UserDatam_AssetBundleNamem_AssetBundleVariantsÿÿ£Gñ×ÜZ56 :!@iÁJ*€7€ÿÿÿÿ¦€²E Þ.(a Þ.€r Þ .
H€«€ÿÿÿÿ 1€1€ÿÿÿÿ @Þ
Q€jH€ê€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jñ€=ÿÿÿÿ1€1€ÿÿÿÿÞ€j€ÿÿÿÿH€›€ÿÿÿÿ1€1€ÿÿÿÿ@ÞQ€jy
 Þ.y€Q Þ. Þ€X!H€iÿÿÿÿ"1€1€ÿÿÿÿ#@Þ$Q€j%H€uÿÿÿÿ&1€1€ÿÿÿÿ'@Þ(Q€j)PPtr<EditorExtension>m_FileIDm_PathIDPPtr<PrefabInstance>m_DefaultReferencesm_Iconm_ExecutionOrderm_ClassNamem_Namespacehh\ày¯È(+!2)¢ÝýG´•¯·°À=Packages/com.unity.ugui/Editor/UI/InterceptedEventsPreview.csày¯InterceptedEventsPreview•*using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using UnityEngine;
using UnityEngine.Profiling;
using UnityEngine.EventSystems;
namespace UnityEditor.Events
{
[CustomPreview(typeof(GameObject))]
/// <summary>
/// Custom preview drawing that will draw the intercepted events of a given object.
/// </summary>
class InterceptedEventsPreview : ObjectPreview
{
protected class ComponentInterceptedEvents
{
public GUIContent componentName;
public int[] interceptedEvents;
}
class Styles
{
public GUIStyle labelStyle = new GUIStyle(EditorStyles.label);
public GUIStyle componentName = new GUIStyle(EditorStyles.boldLabel);
public Styles()
{
Color fontColor = new Color(0.7f, 0.7f, 0.7f);
labelStyle.padding.right += 20;
labelStyle.normal.textColor = fontColor;
labelStyle.active.textColor = fontColor;
labelStyle.focused.textColor = fontColor;
labelStyle.hover.textColor = fontColor;
labelStyle.onNormal.textColor = fontColor;
labelStyle.onActive.textColor = fontColor;
labelStyle.onFocused.textColor = fontColor;
labelStyle.onHover.textColor = fontColor;
componentName.normal.textColor = fontColor;
componentName.active.textColor = fontColor;
componentName.focused.textColor = fontColor;
componentName.hover.textColor = fontColor;
componentName.onNormal.textColor = fontColor;
componentName.onActive.textColor = fontColor;
componentName.onFocused.textColor = fontColor;
componentName.onHover.textColor = fontColor;
}
}
private Dictionary<GameObject, List<ComponentInterceptedEvents>> m_TargetEvents;
private bool m_InterceptsAnyEvent = false;
private GUIContent m_Title;
private Styles m_Styles = new Styles();
public override void Initialize(UnityEngine.Object[] targets)
{
Profiler.BeginSample("ComponentInterceptedEvents.Initialize");
base.Initialize(targets);
m_TargetEvents = new Dictionary<GameObject, List<ComponentInterceptedEvents>>(targets.Count());
m_InterceptsAnyEvent = false;
for (int i = 0; i < targets.Length; ++i)
{
GameObject go = targets[i] as GameObject;
List<ComponentInterceptedEvents> interceptedEvents = GetEventsInfo(go);
m_TargetEvents.Add(go, interceptedEvents);
if (interceptedEvents.Any())
m_InterceptsAnyEvent = true;
}
Profiler.EndSample();
}
public override GUIContent GetPreviewTitle()
{
if (m_Title == null)
{
m_Title = EditorGUIUtility.TrTextContent("Intercepted Events");
}
return m_Title;
}
public override bool HasPreviewGUI()
{
return m_TargetEvents != null && m_InterceptsAnyEvent;
}
public override void OnPreviewGUI(Rect r, GUIStyle background)
{
if (Event.current.type != EventType.Repaint)
return;
Profiler.BeginSample("InterceptedEventsPreview.OnPreviewGUI");
if (m_Styles == null)
m_Styles = new Styles();
Vector2 maxEventLabelSize = Vector2.zero;
int totalInterceptedEvents = 0;
List<ComponentInterceptedEvents> componentIncerceptedEvents = m_TargetEvents[target as GameObject];
// Find out the maximum size needed for any given label.
foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents)
{
foreach (int eventIndex in componentInterceptedEvents.interceptedEvents)
{
GUIContent eventContent = s_PossibleEvents[eventIndex];
++totalInterceptedEvents;
Vector2 labelSize = m_Styles.labelStyle.CalcSize(eventContent);
if (maxEventLabelSize.x < labelSize.x)
{
maxEventLabelSize.x = labelSize.x;
}
if (maxEventLabelSize.y < labelSize.y)
{
maxEventLabelSize.y = labelSize.y;
}
}
}
// Apply padding
RectOffset previewPadding = new RectOffset(-5, -5, -5, -5);
r = previewPadding.Add(r);
// Figure out how many rows and columns we can/should have
int columns = Mathf.Max(Mathf.FloorToInt(r.width / maxEventLabelSize.x), 1);
int rows = Mathf.Max(totalInterceptedEvents / columns, 1) + componentIncerceptedEvents.Count;
// Centering
float initialX = r.x + Mathf.Max(0, (r.width - (maxEventLabelSize.x * columns)) / 2);
float initialY = r.y + Mathf.Max(0, (r.height - (maxEventLabelSize.y * rows)) / 2);
Rect labelRect = new Rect(initialX, initialY, maxEventLabelSize.x, maxEventLabelSize.y);
int currentColumn = 0;
foreach (ComponentInterceptedEvents componentInterceptedEvents in componentIncerceptedEvents)
{
GUI.Label(labelRect, componentInterceptedEvents.componentName, m_Styles.componentName);
labelRect.y += labelRect.height;
labelRect.x = initialX;
foreach (int eventIndex in componentInterceptedEvents.interceptedEvents)
{
GUIContent eventContent = s_PossibleEvents[eventIndex];
GUI.Label(labelRect, eventContent, m_Styles.labelStyle);
if (currentColumn < columns - 1)
{
labelRect.x += labelRect.width;
}
else
{
labelRect.y += labelRect.height;
labelRect.x = initialX;
}
currentColumn = (currentColumn + 1) % columns;
}
if (labelRect.x != initialX)
{
labelRect.y += labelRect.height;
labelRect.x = initialX;
}
}
Profiler.EndSample();
}
//Lookup cache to avoid recalculating which types uses which events:
//Caches all interfaces that inherit from IEventSystemHandler
static List<Type> s_EventSystemInterfaces = null;
//Caches all GUIContents in a single list to avoid creating too much GUIContent and strings.
private static List<GUIContent> s_PossibleEvents = null;
//Caches all events used by each interface
static Dictionary<Type, List<int>> s_InterfaceEventSystemEvents = null;
//Caches each concrete type and it's events
static readonly Dictionary<Type, ComponentInterceptedEvents> s_ComponentEvents2 = new Dictionary<Type, ComponentInterceptedEvents>();
protected static List<ComponentInterceptedEvents> GetEventsInfo(GameObject gameObject)
{
InitializeEvetnsInterfaceCacheIfNeeded();
List<ComponentInterceptedEvents> componentEvents = new List<ComponentInterceptedEvents>();
MonoBehaviour[] mbs = gameObject.GetComponents<MonoBehaviour>();
for (int i = 0, imax = mbs.Length; i < imax; ++i)
{
ComponentInterceptedEvents componentEvent = null;
MonoBehaviour mb = mbs[i];
if (mb == null)
continue;
Type type = mb.GetType();
if (!s_ComponentEvents2.ContainsKey(type))
{
List<int> events = null;
Profiler.BeginSample("ComponentInterceptedEvents.GetEventsInfo.NewType");
if (typeof(IEventSystemHandler).IsAssignableFrom(type))
{
for (int index = 0; index < s_EventSystemInterfaces.Count; index++)
{
var eventInterface = s_EventSystemInterfaces[index];
if (!eventInterface.IsAssignableFrom(type))
continue;
if (events == null)
events = new List<int>();
events.AddRange(s_InterfaceEventSystemEvents[eventInterface]);
}
}
if (events != null)
{
componentEvent = new ComponentInterceptedEvents();
componentEvent.componentName = new GUIContent(type.Name);
componentEvent.interceptedEvents = events.OrderBy(index => s_PossibleEvents[index].text).ToArray();
}
s_ComponentEvents2.Add(type, componentEvent);
Profiler.EndSample();
}
else
{
componentEvent = s_ComponentEvents2[type];
}
if (componentEvent != null)
{
componentEvents.Add(componentEvent);
}
}
return componentEvents;
}
private static void InitializeEvetnsInterfaceCacheIfNeeded()
{
if (s_EventSystemInterfaces != null)
return;
s_EventSystemInterfaces = new List<Type>();
s_PossibleEvents = new List<GUIContent>();
s_InterfaceEventSystemEvents = new Dictionary<Type, List<int>>();
TypeCache.TypeCollection types = TypeCache.GetTypesDerivedFrom<IEventSystemHandler>();
foreach (var type in types)
{
if (!type.IsInterface)
continue;
s_EventSystemInterfaces.Add(type);
List<int> eventIndexList = new List<int>();
MethodInfo[] methodInfos = type.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
for (int mi = 0; mi < methodInfos.Length; mi++)
{
MethodInfo methodInfo = methodInfos[mi];
eventIndexList.Add(s_PossibleEvents.Count);
s_PossibleEvents.Add(new GUIContent(methodInfo.Name));
}
s_InterfaceEventSystemEvents.Add(type, eventIndexList);
}