public void RefreshDataToGfx()
        {
            this.InitData();
            int count = this.transNodeObjs.Count;
            int i;

            for (i = 0; i < this.nodeLst.Count; i++)
            {
                TransNode  transNode  = this.nodeLst[i];
                GameObject gameObject = null;
                string     name       = "CurvlTransNode_" + i;
                if (i >= count)
                {
                    GameObject gameObject2 = this.curvlRootObj;
                    if (gameObject2 != null)
                    {
                        for (int j = 0; j < gameObject2.transform.childCount; j++)
                        {
                            gameObject = gameObject2.transform.GetChild(j).gameObject;
                            string   name2 = gameObject.name;
                            string[] array = name2.Split(new char[]
                            {
                                '_'
                            });
                            int num = -1;
                            int.TryParse(array[1], ref num);
                            if (num == i)
                            {
                                break;
                            }
                            gameObject = null;
                        }
                    }
                    if (gameObject == null)
                    {
                        gameObject                  = (ActionManager.InstantiateObject(this.transObjPrefb) as GameObject);
                        gameObject.name             = name;
                        gameObject.transform.parent = this.curvlRootObj.transform;
                        Camera camera = gameObject.GetComponent <Camera>();
                        if (camera == null && this.useCamera)
                        {
                            camera = gameObject.AddComponent <Camera>();
                        }
                        else if (camera != null && !this.useCamera)
                        {
                            Object.DestroyImmediate(camera);
                        }
                    }
                    this.transNodeObjs.Add(gameObject);
                }
                else
                {
                    gameObject = this.transNodeObjs[i];
                    if (gameObject == null)
                    {
                        gameObject                  = (ActionManager.InstantiateObject(this.transObjPrefb) as GameObject);
                        gameObject.name             = name;
                        gameObject.transform.parent = this.curvlRootObj.transform;
                        Camera camera2 = gameObject.GetComponent <Camera>();
                        if (camera2 == null && this.useCamera)
                        {
                            camera2 = gameObject.AddComponent <Camera>();
                        }
                        else if (camera2 != null && !this.useCamera)
                        {
                            Object.DestroyImmediate(camera2);
                        }
                        this.transNodeObjs[i] = gameObject;
                    }
                }
                Transform transform = gameObject.transform;
                gameObject.SetActive(true);
                transform.position = transNode.pos;
                transform.rotation = transNode.rot;
            }
            for (int k = i; k < count; k++)
            {
                this.transNodeObjs[k].SetActive(false);
            }
        }
示例#2
0
        public void RefreshDataToGfx()
        {
            this.InitData();
            int count = this.transNodeObjs.Count;
            int num2  = 0;

            while (num2 < this.nodeLst.Count)
            {
                TransNode  node = this.nodeLst[num2];
                GameObject item = null;
                string     str  = "CurvlTransNode_" + num2;
                if (num2 >= count)
                {
                    GameObject curvlRootObj = this.curvlRootObj;
                    if (curvlRootObj != null)
                    {
                        for (int j = 0; j < curvlRootObj.transform.childCount; j++)
                        {
                            item = curvlRootObj.transform.GetChild(j).gameObject;
                            char[]   separator = new char[] { '_' };
                            string[] strArray  = item.name.Split(separator);
                            int      result    = -1;
                            int.TryParse(strArray[1], out result);
                            if (result == num2)
                            {
                                break;
                            }
                            item = null;
                        }
                    }
                    if (item == null)
                    {
                        item                  = ActionManager.InstantiateObject(this.transObjPrefb) as GameObject;
                        item.name             = str;
                        item.transform.parent = this.curvlRootObj.transform;
                        Camera component = item.GetComponent <Camera>();
                        if ((component == null) && this.useCamera)
                        {
                            component = item.AddComponent <Camera>();
                        }
                        else if ((component != null) && !this.useCamera)
                        {
                            UnityEngine.Object.DestroyImmediate(component);
                        }
                    }
                    this.transNodeObjs.Add(item);
                }
                else
                {
                    item = this.transNodeObjs[num2];
                    if (item == null)
                    {
                        item                  = ActionManager.InstantiateObject(this.transObjPrefb) as GameObject;
                        item.name             = str;
                        item.transform.parent = this.curvlRootObj.transform;
                        Camera camera2 = item.GetComponent <Camera>();
                        if ((camera2 == null) && this.useCamera)
                        {
                            camera2 = item.AddComponent <Camera>();
                        }
                        else if ((camera2 != null) && !this.useCamera)
                        {
                            UnityEngine.Object.DestroyImmediate(camera2);
                        }
                        this.transNodeObjs[num2] = item;
                    }
                }
                Transform transform = item.transform;
                item.SetActive(true);
                transform.position = node.pos;
                transform.rotation = node.rot;
                num2++;
            }
            for (int i = num2; i < count; i++)
            {
                this.transNodeObjs[i].SetActive(false);
            }
        }