using System; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Collections; using System.Collections.Generic; namespace UnityEngine { internal class GUIStateObjects { static Dictionary s_StateCache = new Dictionary(); [System.Security.SecuritySafeCritical] static internal object GetStateObject (System.Type t, int controlID) { object o; if (s_StateCache.TryGetValue(controlID, out o) == false || o.GetType() != t) { o = System.Activator.CreateInstance(t); s_StateCache[controlID] = o; } return o; } static internal object QueryStateObject (System.Type t, int controlID) { object o = s_StateCache[controlID]; if (t.IsInstanceOfType (o)) return o; return null; } } } // namespace