예제 #1
0
        private void LoadBackGround(int theme)
        {
            var back = this.GetComponentInChildren <SceneLevelBackwardsRenderer>();

            if (back != null)
            {
                var spp = back.GetComponent <SpriteRenderer>();
                if (spp == null)
                {
#if UNITY_EDITOR
                    Debug.LogError("can not find theme bg sprintrenderer");
#endif
                    return;
                }
                var tex = MapLoader.ins.LoadEdotorImageThemeBgV1(theme);; // (Texture2D)PrefabsMgr.Load<Object>("Map/Image/theme_bg/" + map.theme.ToString());
                if (tex == null)
                {
#if UNITY_EDITOR
                    Debug.LogError("can not find theme id=" + theme);
#endif
                    return;
                }
                var sp = Sprite.Create(tex, new Rect(new Vector2(0, 0), new Vector2(tex.width, tex.height)), new Vector2(0.5f, 0.5f));
                spp.sprite = sp;
                back.SetScale(true);
                //紧凑模式 不显示特效
                if (DevConfig.MemoryOrCpuUseageTypeIsTie == false)
                {
                    var bgEffectTransform = back.transform.Find("BgEffect");
                    if (bgEffectTransform != null)
                    {
                        GameObject.Destroy(bgEffectTransform.gameObject);
                    }
                    var needBgEffect = MapEditorConfig.GetNeedBgEffect(theme);
                    if (needBgEffect)
                    {
                        back.SetDefaultBgEffect(false);
                        var effectParent   = back.transform;
                        var bgEffectPrefab = MapLoader.ins.LoadBgEffectV1(theme);
                        if (bgEffectPrefab != null)
                        {
                            var bgEffect = GameObject.Instantiate <GameObject>(bgEffectPrefab, effectParent);
                            bgEffect.name = "BgEffect";
                            bgEffect.transform.localPosition = Vector3.zero;
                        }
                    }
                    else
                    {
                        back.SetDefaultBgEffect(true);
                    }
                }
            }
        }
예제 #2
0
        public void ChangeBackGround(int theme)
        {
            var obj = GameObject.Find("Maps/BackGround");

            if (obj == null)
            {
                return;
            }
            var back = obj.GetComponent <SceneLevelBackwardsRenderer>();

            if (back == null)
            {
                return;
            }
            var spp = back.GetComponent <SpriteRenderer>();

            if (spp == null || MapLoader.ins == null)
            {
                return;
            }

            var tex = MapLoader.ins.LoadEdotorImageThemeBgV1(theme);   // (Texture2D)PrefabsMgr.Load<Object>("Map/Image/theme_bg/" + theme.ToString());

            if (tex == null)
            {
                //  Debug.Assert(false);
                return;
            }
            var sp = Sprite.Create(tex, new Rect(new Vector2(0, 0), new Vector2(tex.width, tex.height)), new Vector2(0.5f, 0.5f));

            spp.sprite = sp;
            back.SetScale(true);

            var bgEffectTransform = back.transform.Find("BgEffect");

            if (bgEffectTransform != null)
            {
                GameObject.Destroy(bgEffectTransform.gameObject);
            }
            var needBgEffect = MapEditorConfig.GetNeedBgEffect(theme);

            if (needBgEffect)
            {
                var effectParent   = back.transform;
                var bgEffectPrefab = MapLoader.ins.LoadBgEffectV1(theme);
                if (bgEffectPrefab != null)
                {
                    var bgEffect = GameObject.Instantiate <GameObject>(bgEffectPrefab, effectParent);
                    bgEffect.name = "BgEffect";
                    bgEffect.transform.localPosition = Vector3.zero;
                }
            }
        }
예제 #3
0
        private void LoadBackGround(int theme)
        {
            var back = this.GetComponentInChildren <BackGround>();

            if (back != null)
            {
                var spp = back.GetComponent <SpriteRenderer>();

                var tex = MapLoader.ins.LoadEdotorImageThemeBgV1(theme);; // (Texture2D)PrefabsMgr.Load<Object>("Map/Image/theme_bg/" + map.theme.ToString());
                if (tex == null)
                {
                    Debug.Assert(false);
                }
                var sp = Sprite.Create(tex, new Rect(new Vector2(0, 0), new Vector2(tex.width, tex.height)), new Vector2(0.5f, 0.5f));
                spp.sprite = sp;

                var bgEffectTransform = back.transform.Find("BgEffect");
                if (bgEffectTransform != null)
                {
                    GameObject.Destroy(bgEffectTransform.gameObject);
                }
                var needBgEffect = MapEditorConfig.GetNeedBgEffect(theme);
                if (needBgEffect)
                {
                    back.SetDefaultBgEffect(false);
                    var effectParent   = back.transform;
                    var bgEffectPrefab = MapLoader.ins.LoadBgEffectV1(theme);
                    if (bgEffectPrefab != null)
                    {
                        var bgEffect = GameObject.Instantiate <GameObject>(bgEffectPrefab, effectParent);
                        bgEffect.name = "BgEffect";
                        bgEffect.transform.localPosition = Vector3.zero;
                    }
                }
                else
                {
                    back.SetDefaultBgEffect(true);
                }
            }
        }