You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
985 B
40 lines
985 B
3 years ago
|
using FairyGUI;
|
||
|
using System.Collections.Generic;
|
||
|
|
||
|
namespace ET
|
||
|
{
|
||
|
public static class GObjectHelper
|
||
|
{
|
||
|
private static Dictionary<GObject, FUI> keyValuePairs = new Dictionary<GObject, FUI>();
|
||
|
|
||
|
public static T Get<T>(this GObject self) where T : FUI
|
||
|
{
|
||
|
if (self != null && keyValuePairs.ContainsKey(self))
|
||
|
{
|
||
|
return keyValuePairs[self] as T;
|
||
|
}
|
||
|
|
||
|
return default(T);
|
||
|
}
|
||
|
|
||
|
public static void Add(this GObject self, FUI fui)
|
||
|
{
|
||
|
if (self != null && fui != null)
|
||
|
{
|
||
|
keyValuePairs[self] = fui;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
public static FUI Remove(this GObject self)
|
||
|
{
|
||
|
if (self != null && keyValuePairs.ContainsKey(self))
|
||
|
{
|
||
|
var result = keyValuePairs[self];
|
||
|
keyValuePairs.Remove(self);
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
return null;
|
||
|
}
|
||
|
}
|
||
|
}
|