Exemplo n.º 1
0
        public override bool Equals(object obj)
        {
            var other = obj as SceneManagerKun;

            if (obj == null)
            {
                return(false);
            }
            if (sceneKuns == null && other.sceneKuns == null)
            {
                return(true);
            }
            if (sceneKuns == null && other.sceneKuns != null)
            {
                return(false);
            }
            if (sceneKuns != null && other.sceneKuns == null)
            {
                return(false);
            }
            if (sceneKuns.Length != other.sceneKuns.Length)
            {
                return(false);
            }
            for (var i = 0; i < sceneKuns.Length; i++)
            {
                if (!SceneKun.Equals(sceneKuns[i], other.sceneKuns[i]))
                {
                    return(false);
                }
            }
            return(true);
        }
Exemplo n.º 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="binaryReader"></param>
        public void OnMessageEventPull(BinaryReader binaryReader)
        {
            var scene    = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
            var sceneKun = new SceneKun(scene);

            UnityChoseKunPlayer.SendMessage <SceneKun>(UnityChoseKun.MessageID.GameObjectPull, sceneKun);
        }
Exemplo n.º 3
0
 GameObjectKun GetGameObjectKunInSceneKun(int instanceID, SceneKun sceneKun)
 {
     if (sceneKun != null && sceneKun.gameObjectKuns != null)
     {
         return(sceneKun.gameObjectKuns.Where((g) => g.instanceID == instanceID).FirstOrDefault());
     }
     return(null);
 }
Exemplo n.º 4
0
 public SceneManagerKun(bool isCreate = false)
 {
     if (isCreate)
     {
         var len = SceneManager.sceneCount;
         mSceneKuns = new SceneKun[len];
         for (var i = 0; i < len; i++)
         {
             var scene = SceneManager.GetSceneAt(i);
             mSceneKuns[i] = new SceneKun(scene);
         }
     }
 }
Exemplo n.º 5
0
        public virtual void Deserialize(BinaryReader binaryReader)
        {
            var len = binaryReader.ReadInt32();

            if (len != -1)
            {
                mSceneKuns = new SceneKun[len];
                for (var i = 0; i < mSceneKuns.Length; i++)
                {
                    mSceneKuns[i] = new SceneKun();
                    mSceneKuns[i].Deserialize(binaryReader);
                }
            }
        }
Exemplo n.º 6
0
        public void MoveGameObjectToScene(GameObjectKun gameObjectKun, SceneKun sceneKun)
        {
            // RootGameObjectの場合、元のSceneから削除する
            for (var i = 0; i < sceneKuns.Length; i++)
            {
                var list = new List <GameObjectKun>(sceneKuns[i].gameObjectKuns);
                if (list.Contains(gameObjectKun))
                {
                    list.Remove(gameObjectKun);
                    sceneKuns[i].gameObjectKuns = list.ToArray();
                    break;
                }
            }

            // 移動先のSceneへ追加
            {
                var list = new List <GameObjectKun>(sceneKun.gameObjectKuns);
                list.Add(gameObjectKun);
                sceneKun.gameObjectKuns            = list.ToArray();
                gameObjectKun.transformKun.sceneHn = sceneKun.handle;
            }
        }
Exemplo n.º 7
0
        public void OnMessageEventPush(BinaryReader binaryReader)
        {
            HierarchyMessage message = new HierarchyMessage();

            message.Deserialize(binaryReader);

            switch (message.messageID)
            {
            case HierarchyMessage.MessageID.Duplicate:
            {
                var go = FindGameObjectInScene(message.baseID);
                if (go != null)
                {
                    var clone = GameObject.Instantiate(go);
                    clone.transform.parent        = go.transform.parent;
                    clone.transform.localPosition = go.transform.localPosition;
                    clone.transform.localRotation = go.transform.localRotation;
                    clone.transform.localScale    = go.transform.localScale;
                }
            }
            break;

            case HierarchyMessage.MessageID.Delete:
            {
                var go = FindGameObjectInScene(message.baseID);
                if (go != null)
                {
                    GameObject.DestroyImmediate(go);
                }
            }
            break;

            case HierarchyMessage.MessageID.CreateEmpty:
            {
                var parent = FindGameObjectInScene(message.baseID);
                var go     = new GameObject();
                if (go != null)
                {
                    if (parent != null)
                    {
                        go.transform.parent = parent.transform;
                    }
                    else
                    {
                        go.transform.parent = null;
                    }

                    go.transform.localPosition = Vector3.zero;
                    go.transform.localRotation = Quaternion.identity;
                    go.transform.localScale    = Vector3.one;
                }
            }
            break;

            case HierarchyMessage.MessageID.CreateClass:
            {
                var parent = FindGameObjectInScene(message.baseID);
                var go     = new GameObject(message.type.Name, message.type);
                if (go != null)
                {
                    if (parent != null)
                    {
                        go.transform.parent = parent.transform;
                    }
                    else
                    {
                        go.transform.parent = null;
                    }

                    go.transform.localPosition = Vector3.zero;
                    go.transform.localRotation = Quaternion.identity;
                    go.transform.localScale    = Vector3.one;
                }
            }
            break;

            case HierarchyMessage.MessageID.CreatePrimitive:
            {
                var parent = FindGameObjectInScene(message.baseID);
                var go     = GameObject.CreatePrimitive(message.primitiveType);
                if (go != null)
                {
                    if (parent != null)
                    {
                        go.transform.parent = parent.transform;
                    }
                    else
                    {
                        go.transform.parent = null;
                    }

                    go.transform.localPosition = Vector3.zero;
                    go.transform.localRotation = Quaternion.identity;
                    go.transform.localScale    = Vector3.one;
                }
            }
            break;
            }

            var scene    = UnityEngine.SceneManagement.SceneManager.GetActiveScene();
            var sceneKun = new SceneKun(scene);

            UnityChoseKunPlayer.SendMessage <SceneKun>(UnityChoseKun.MessageID.GameObjectPull, sceneKun);
        }