Beispiel #1
0
        /// <summary>
        /// Register a BlendSystemUser as using this Blend System
        /// </summary>
        /// <param name="user"></param>
        public void Register(BlendSystemUser user)
        {
            List <BlendSystemUser> newUsers = new List <BlendSystemUser>();

            for (int i = 0; i < users.Length; i++)
            {
                newUsers.Add(users[i]);
            }

            if (newUsers.Contains(user))
            {
                Debug.LogError("Could not register " + user.GetType().Name + " component to " + GetType().Name + ". BlendSystemUser is already registered.");
            }
            else
            {
                newUsers.Add(user);
                user.blendSystem = this;
            }

            users = newUsers.ToArray();
        }
Beispiel #2
0
        /// <summary>
        /// Unregister a BlendSystemUser
        /// </summary>
        /// <param name="user"></param>
        public void Unregister(BlendSystemUser user)
        {
            List <BlendSystemUser> newUsers = new List <BlendSystemUser>();

            for (int i = 0; i < users.Length; i++)
            {
                newUsers.Add(users[i]);
            }

            if (newUsers.Contains(user))
            {
                if (user != null)
                {
                    user.blendSystem = null;
                }
                newUsers.Remove(user);
            }
            else
            {
                Debug.LogError("Could not unregister " + user.GetType().Name + " component from " + GetType().Name + ". BlendSystemUser is not registered to this Blend System.");
            }

            users = newUsers.ToArray();

            if (users.Length == 0)
            {
                OnBlendSystemRemoved();

                if (Application.isPlaying)
                {
                    Destroy(this);
                }
                else
                {
                    DestroyImmediate(this);
                }
            }
        }