Ejemplo n.º 1
0
    public void Collect(TsSceneSwitcher.ESceneType eSceneType, GameObject go)
    {
        if (!TsSceneSwitcher.IsValidSceneType(eSceneType) || go == null)
        {
            TsLog.LogWarning("Invalid SceneType[{0}] go[{1}]", new object[]
            {
                eSceneType,
                (!(go == null)) ? go.name : "null"
            });
            return;
        }
        GameObject gameObject = this._MakeRootSceneGO(eSceneType);

        this._AddOrGetComponent(go, eSceneType);
        this._Collect(go, gameObject, eSceneType, gameObject.activeInHierarchy);
    }
Ejemplo n.º 2
0
    public void CollectAllMapGameObjects(TsSceneSwitcher.ESceneType eSceneType, bool isActive)
    {
        if (!TsSceneSwitcher.IsValidSceneType(eSceneType))
        {
            TsLog.LogWarning("Invalid SceneType= " + eSceneType, new object[0]);
            return;
        }
        GameObject rootGO     = this._MakeRootSceneGO(eSceneType);
        GameObject gameObject = this._GetBundle_RootSceneGO(eSceneType);

        if (gameObject == null)
        {
            return;
        }
        this._TraverseToSetMarkAndCollect(rootGO, gameObject, eSceneType);
    }
Ejemplo n.º 3
0
    public void Switch(TsSceneSwitcher.ESceneType eSceneType)
    {
        if (!TsSceneSwitcher.IsValidSceneType(eSceneType))
        {
            TsLog.LogWarning("Invalid SceneType= " + eSceneType, new object[0]);
            return;
        }
        GameObject x = this._GetSwitchData_RootSceneGO(eSceneType);

        if (x == null)
        {
            return;
        }
        foreach (KeyValuePair <GameObject, TsSceneSwitcher._SwitchDataList> current in this._switchDataDic)
        {
            bool flag = false;
            if (x == current.Key)
            {
                flag = true;
            }
            foreach (TsSceneSwitcher.SwitchData current2 in current.Value)
            {
                try
                {
                    if (current2.TargetGO)
                    {
                        this._SetSwitchData(current2.TargetGO, current2);
                        NkUtil.SetChildActiveExceptChar(current2.TargetGO, flag);
                        if (current2.TargetGO.activeInHierarchy)
                        {
                            if (current2.EnableRender != TsSceneSwitcher.SwitchData.ERender.Not_Have)
                            {
                                current2.TargetGO.renderer.enabled = (current2.EnableRender == TsSceneSwitcher.SwitchData.ERender.Enable);
                            }
                            if (current2.IsPlayingAudio != TsSceneSwitcher.SwitchData.EAudio.Not_Have && current2.IsPlayingAudio == TsSceneSwitcher.SwitchData.EAudio.Playing)
                            {
                                TsAudioAdapter component = current2.TargetGO.GetComponent <TsAudioAdapter>();
                                if (component != null)
                                {
                                    component.GetAudioEx().RestoreToPlay();
                                }
                            }
                            if (current2.IsPlayingAnimation != TsSceneSwitcher.SwitchData.EAnimation.Not_Have && current2.IsPlayingAnimation == TsSceneSwitcher.SwitchData.EAnimation.Playing)
                            {
                                Animation animation = current2.TargetGO.animation;
                                if (null != animation)
                                {
                                    AnimationState animationState = current2.TargetGO.animation[animation.clip.name];
                                    if (null != animationState)
                                    {
                                        float time = UnityEngine.Random.Range(0f, animationState.length);
                                        animationState.time = time;
                                        animation.Play();
                                    }
                                }
                            }
                            Terrain componentInChildren = current2.TargetGO.GetComponentInChildren <Terrain>();
                            if (componentInChildren != null)
                            {
                                componentInChildren.enabled = flag;
                            }
                            Camera componentInChildren2 = current2.TargetGO.GetComponentInChildren <Camera>();
                            if (componentInChildren2 != null)
                            {
                                componentInChildren2.enabled = flag;
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    TsLog.LogError("DataName= " + current2.TargetGOName + "   Exception= " + ex.ToString(), new object[0]);
                }
            }
        }
        this.CurrentSceneType = eSceneType;
    }