Пример #1
0
    private void _Collect(GameObject go, GameObject rootGO, TsSceneSwitcher.ESceneType eSceneType, bool isActive)
    {
        if (go == null || rootGO == null)
        {
            TsLog.LogError("Cannot be null~!!!!! ", new object[0]);
            return;
        }
        TsSceneSwitcherMark tsSceneSwitcherMark = go.GetComponent <TsSceneSwitcherMark>();

        if (tsSceneSwitcherMark == null)
        {
            tsSceneSwitcherMark = this._AddOrGetComponent(go, eSceneType);
            if (tsSceneSwitcherMark == null)
            {
                TsLog.LogError("Must Added~! Check logic~!", new object[0]);
                return;
            }
        }
        if (tsSceneSwitcherMark.IsCollected)
        {
            return;
        }
        if (go.transform.parent == null)
        {
            go.transform.parent = rootGO.transform;
        }
        TsSceneSwitcher._SwitchDataList switchDataList = this._GetSwitchData_List(eSceneType);
        if (switchDataList == null)
        {
            TsLog.LogError("Cannot found~! key= " + rootGO.name, new object[0]);
            return;
        }
        TsSceneSwitcher.SwitchData switchData = this._MakeSwitchData(tsSceneSwitcherMark, rootGO.name);
        if (switchData != null)
        {
            tsSceneSwitcherMark.RootGOName    = rootGO.name;
            tsSceneSwitcherMark.IsCollected   = true;
            tsSceneSwitcherMark.RefSwitchData = switchData;
            switchDataList.Add(switchData);
        }
        Light[] componentsInChildren = go.GetComponentsInChildren <Light>();
        if (componentsInChildren != null)
        {
            Light[] array = componentsInChildren;
            for (int i = 0; i < array.Length; i++)
            {
                Light       light     = array[i];
                TsLayerMask layerMask = new TsLayerMask((uint)light.cullingMask);
                light.cullingMask = layerMask - TsLayer.GUI;
            }
        }
        go.SetActive(isActive);
    }
Пример #2
0
    private TsSceneSwitcherMark _AddOrGetComponent(GameObject go, TsSceneSwitcher.ESceneType eSceneType)
    {
        if (go == null)
        {
            return(null);
        }
        TsSceneSwitcherMark tsSceneSwitcherMark = go.GetComponent <TsSceneSwitcherMark>();

        if (tsSceneSwitcherMark == null)
        {
            tsSceneSwitcherMark = go.AddComponent <TsSceneSwitcherMark>();
        }
        tsSceneSwitcherMark.SceneType = eSceneType;
        return(tsSceneSwitcherMark);
    }
Пример #3
0
    private GameObject _MakeRootSceneGO(TsSceneSwitcher.ESceneType eSceneType)
    {
        GameObject gameObject = this._GetSwitchData_RootSceneGO(eSceneType);

        if (gameObject == null)
        {
            gameObject = new GameObject(eSceneType.ToString());
            TsSceneSwitcherMark tsSceneSwitcherMark = this._AddOrGetComponent(gameObject, eSceneType);
            tsSceneSwitcherMark.RootGOName  = eSceneType.ToString();
            tsSceneSwitcherMark.IsCollected = true;
            TsSceneSwitcher._SwitchDataList value = new TsSceneSwitcher._SwitchDataList();
            this._switchDataDic.Add(gameObject, value);
            gameObject.transform.parent = TsSceneSwitcher.Instance.gameObject.transform;
            UnityEngine.Object.DontDestroyOnLoad(gameObject);
        }
        return(gameObject);
    }
    private List <GameObject> FindCurrentSceneTypeObjs()
    {
        string     name       = TsSceneSwitcher.Instance.CurrentSceneType.ToString();
        GameObject gameObject = this.FindGameObject(name);

        TsSceneSwitcherMark[] componentsInChildren = gameObject.transform.GetComponentsInChildren <TsSceneSwitcherMark>();
        if (componentsInChildren == null)
        {
            UnityEngine.Debug.LogError("ERROR,  Behavior_Test.cs, FindCurrentSceneTypeObjs(), sceneObjs is Null : ");
            return(null);
        }
        List <GameObject> list = new List <GameObject>();

        TsSceneSwitcherMark[] array = componentsInChildren;
        for (int i = 0; i < array.Length; i++)
        {
            TsSceneSwitcherMark tsSceneSwitcherMark = array[i];
            list.Add(tsSceneSwitcherMark.gameObject);
        }
        return(list);
    }
Пример #5
0
 private TsSceneSwitcher.SwitchData _MakeSwitchData(TsSceneSwitcherMark mark, string rootSceneGOName)
 {
     TsSceneSwitcher.SwitchData switchData = new TsSceneSwitcher.SwitchData();
     this._SetSwitchData(mark.gameObject, switchData);
     return(switchData);
 }