Esempio n. 1
0
        public static void Destroy(object gameObject)
        {
            Integrity.EnsureNotNull(gameObject);
            Integrity.EnsureGameObject(gameObject);

            var destroy = ObjectType.GetMethod(
                "Destroy",
                new Type[] { ObjectType, typeof(float) }
                );

            destroy.Invoke(null, new[] { gameObject, 0f });
        }
Esempio n. 2
0
        public static void SetActive(object gameObject, bool active)
        {
            Integrity.EnsureNotNull(gameObject);
            Integrity.EnsureGameObject(gameObject);

            var setActive = GameObjectType.GetMethod(
                Resources.UnityEngine.GameObjectSetActiveMethodName,
                BindingFlags.Public | BindingFlags.Instance
                );

            setActive.Invoke(gameObject, new object[] { active });
        }
Esempio n. 3
0
        public static void DontDestroyOnLoad(object gameObject)
        {
            Integrity.EnsureNotNull(gameObject);
            Integrity.EnsureGameObject(gameObject);

            var dontDestroy = ObjectType.GetMethod(
                Resources.UnityEngine.ObjectDontDestroyOnLoadMethodName,
                BindingFlags.Public | BindingFlags.Static
                );

            dontDestroy.Invoke(null, new[] { gameObject });
        }
Esempio n. 4
0
        public static object AttachComponentTo(object gameObject, Type componentType)
        {
            Integrity.EnsureNotNull(gameObject);
            Integrity.EnsureGameObject(gameObject);

            var addComponent = GameObjectType.GetMethod(
                Resources.UnityEngine.GameObjectAddComponentMethodName,
                new[] { typeof(Type) }
                );

            Integrity.EnsureNotNull(componentType);
            return(addComponent.Invoke(gameObject, new object[] { componentType }));
        }