Ejemplo n.º 1
0
 private void Add(string item, TypeCapabilities caps)
 {
     if (!dict.ContainsKey(item))
     {
         dict.Add(item, caps);
     }
 }
Ejemplo n.º 2
0
        public bool HasCaps(Type tp, TypeCapabilities caps)
        {
            if (dict.ContainsKey(tp.Name))
            {
                return((dict[tp.Name] & caps) == caps);
            }
            TypeCapabilities c = Add(tp);

            return((c & caps) == caps);
        }
Ejemplo n.º 3
0
        public TypeCapabilities Add(Type tp)
        {
            TypeCapabilities caps = TypeCapabilities.None;

            if (tp.IsSubclassOf(typeof(Component)))
            {
                MethodInfo info = tp.GetMethod("Update");
                if (info != null && info.DeclaringType != typeof(MonoBehaviour))
                {
                    caps |= TypeCapabilities.Update;
                }

                info = tp.GetMethod("LateUpdate");
                if (info != null && info.DeclaringType != typeof(MonoBehaviour))
                {
                    caps |= TypeCapabilities.LateUpdate;
                }

                info = tp.GetMethod("FixedUpdate");
                if (info != null && info.DeclaringType != typeof(MonoBehaviour))
                {
                    caps |= TypeCapabilities.FixedUpdate;
                }

                info = tp.GetMethod("Awake");
                if (info != null && info.DeclaringType != typeof(Component))
                {
                    caps |= TypeCapabilities.Awake;
                }

                info = tp.GetMethod("OnGUI");
                if (info != null && info.DeclaringType != typeof(MonoBehaviour))
                {
                    caps |= TypeCapabilities.GUI;
                }
                Add(tp.Name, caps);
            }
            else
            {
                // MonoBehaviours and components does not need to check for FixReferences and we do not wnat other random types to muck up the type set
                if (tp.GetCustomAttributes(typeof(FixReferencesAttribute), true).Length > 0)
                {
                    caps |= TypeCapabilities.FixReferences;
                    Add(tp.Name, caps);
                }
            }
            return(caps);
        }
Ejemplo n.º 4
0
 private void Add(string item, TypeCapabilities caps)
 {
     if (!dict.ContainsKey(item))
     {
         dict.Add(item, caps);
     }
 }
Ejemplo n.º 5
0
 public bool HasCaps(Type tp, TypeCapabilities caps)
 {
     if (dict.ContainsKey(tp.Name))
     {
         return (dict[tp.Name] & caps) == caps;
     }
     TypeCapabilities c = Add(tp);
     return (c & caps) == caps;
 }