示例#1
0
    public void OnInitCameraBloom(Camera cam, Engine.JsonObject bloom)
    {
        if (bloom == null)
        {
            return;
        }

        string strBloomName = bloom["name"];

        if (!string.IsNullOrEmpty(strBloomName))
        {
            UnityStandardAssets.ImageEffects.BloomAndFlares bloomEffect = null;
            if (strBloomName == "BloomAndFlares")
            {
                //避免重复添加
                bloomEffect = cam.gameObject.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>();
                if (bloomEffect == null)
                {
                    bloomEffect = cam.gameObject.AddComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>();
                }

                if (bloomEffect != null)
                {
                    bloomEffect.lensFlareShader            = Shader.Find("Hidden/LensFlareCreate");
                    bloomEffect.vignetteShader             = Shader.Find("Hidden/Vignetting");
                    bloomEffect.separableBlurShader        = Shader.Find("Hidden/SeparableBlurPlus");
                    bloomEffect.addBrightStuffOneOneShader = Shader.Find("Hidden/BlendOneOne");
                    bloomEffect.screenBlendShader          = Shader.Find("Hidden/Blend");
                    bloomEffect.hollywoodFlaresShader      = Shader.Find("Hidden/MultipassHollywoodFlares");
                    bloomEffect.brightPassFilterShader     = Shader.Find("Hidden/BrightPassFilterForBloom");

                    bloomEffect.tweakMode       = (UnityStandardAssets.ImageEffects.TweakMode34)((int)bloom["TweakMode"]);
                    bloomEffect.screenBlendMode = (UnityStandardAssets.ImageEffects.BloomScreenBlendMode)((int)bloom["BlendMode"]);
                    bloomEffect.hdr             = (UnityStandardAssets.ImageEffects.HDRBloomMode)((int)bloom["HDR"]);

                    bloomEffect.bloomIntensity      = bloom["Intensity"];
                    bloomEffect.bloomThreshold      = bloom["Threshold"];
                    bloomEffect.bloomBlurIterations = bloom["BlurIterations"];
                    bloomEffect.sepBlurSpread       = bloom["BlurSpread"];
                    bloomEffect.lensflares          = false;
                    bloomEffect.useSrcAlphaAsMask   = 0f;

                    m_lstEffects.Add(bloomEffect);
                }
            }
        }
    }
示例#2
0
    IEnumerator LoadScene(string sceneName, LoadSceneMode loadMode, Action <GameObject> callback)
    {
        AssetBundle sceneab = null;

        if (Application.isEditor)
        {
            sceneab = Engine.RareEngine.LoadFromFile("loginscene/" + sceneName.ToLower() + ".scene");
        }
        else
        {
            if (Application.platform == RuntimePlatform.Android)
            {
                string strPath = System.IO.Path.Combine(Application.persistentDataPath + "/assets/", "loginscene/" + sceneName.ToLower() + ".scene");
                sceneab = AssetBundle.LoadFromFile(strPath);
                if (sceneab == null)
                {
                    strPath = System.IO.Path.Combine(Application.streamingAssetsPath, "loginscene/" + sceneName.ToLower() + ".scene");
                    sceneab = AssetBundle.LoadFromFile(strPath);
                }
            }
            else
            {
                string strPath = Application.persistentDataPath + "/loginscene/" + sceneName.ToLower() + ".scene";
                sceneab = AssetBundle.LoadFromFile(strPath);
                if (sceneab == null)
                {
                    strPath = System.IO.Path.Combine(Application.streamingAssetsPath, "loginscene/" + sceneName.ToLower() + ".scene");
                    sceneab = AssetBundle.LoadFromFile(strPath);
                }
            }
        }

        AsyncOperation asyn = UnityEngine.SceneManagement.SceneManager.LoadSceneAsync(sceneName, loadMode);

        yield return(asyn);

        if (sceneab != null)
        {
            sceneab.Unload(false);
        }

        SwitchSceneDisable(sceneName);

        GameObject sceneRoot = GetSceneRoot(sceneName);

        if (sceneRoot != null)
        {
            Transform camera = sceneRoot.transform.Find("MainCamera");
            if (camera != null)
            {
                if (camera.GetComponent <AudioListener>())
                {
                    GameObject.Destroy(camera.GetComponent <AudioListener>());
                }

                AudioSource audioSource = camera.GetComponent <AudioSource>();
                if (audioSource != null)
                {
                    Client.IGameOption option = Client.ClientGlobal.Instance().gameOption;
                    if (option != null)
                    {
                        //audioSource.volume = option.GetInt
                        float volume = option.GetInt("Sound", "soundslider", 1);
                        audioSource.volume = ((float)volume) / 100.0f;
                    }
                }

                if (sceneName == CHOOSEROLESCENE)
                {
                    Camera cam = camera.GetComponent <Camera>();
                    cam.cullingMask = -1 - (1 << LayerMask.NameToLayer("UI"));
                    UnityStandardAssets.ImageEffects.BloomAndFlares bloom = camera.GetComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>();
                    if (bloom == null)
                    {
                        bloom = camera.gameObject.AddComponent <UnityStandardAssets.ImageEffects.BloomAndFlares>();
                        bloom.lensFlareShader            = Shader.Find("Hidden/LensFlareCreate");
                        bloom.vignetteShader             = Shader.Find("Hidden/Vignetting");
                        bloom.separableBlurShader        = Shader.Find("Hidden/SeparableBlurPlus");
                        bloom.addBrightStuffOneOneShader = Shader.Find("Hidden/BlendOneOne");
                        bloom.screenBlendShader          = Shader.Find("Hidden/Blend");
                        bloom.hollywoodFlaresShader      = Shader.Find("Hidden/MultipassHollywoodFlares");
                        bloom.brightPassFilterShader     = Shader.Find("Hidden/BrightPassFilterForBloom");

                        bloom.tweakMode           = UnityStandardAssets.ImageEffects.TweakMode34.Complex;
                        bloom.screenBlendMode     = UnityStandardAssets.ImageEffects.BloomScreenBlendMode.Screen;
                        bloom.hdr                 = UnityStandardAssets.ImageEffects.HDRBloomMode.Auto;
                        bloom.lensflares          = false;
                        bloom.bloomIntensity      = 0.3f;
                        bloom.bloomThreshold      = 0.25f;
                        bloom.bloomBlurIterations = 2;
                        bloom.sepBlurSpread       = 1.5f;
                        bloom.useSrcAlphaAsMask   = 0f;
                    }
                }
                else if (sceneName == LOGINSCENE)
                {
                    //登录界面 场景 晃动效果
                    sceneRoot.AddComponent <LoginSceneGyr>();
                }
            }
        }
        if (callback != null)
        {
            callback(sceneRoot);
        }
    }
    // Update is called once per frame
    void Update()
    {
        //if ( PlayerFactory.mMainPlayer == null )
        //    return;

        if (Mathf.Abs(GrayScale - GrayScaleWanted) < 0.001f)
        {
            GrayScale = GrayScaleWanted;
        }
        else
        {
            GrayScale += (GrayScaleWanted - GrayScale) * _Dumper;
        }

        if (Mathf.Abs(BlurThreshold - BlurThresholdWanted) < 0.001f)
        {
            BlurThreshold = BlurThresholdWanted;
        }
        else
        {
            BlurThreshold += (BlurThresholdWanted - BlurThreshold) * _Dumper;
        }

        GrayscaleEffect    gs = gameObject.GetComponent <GrayscaleEffect>();
        BloomAndLensFlares bf = gameObject.GetComponent <BloomAndLensFlares>();

        if (gs == null)
        {
            return;
        }
        if (GrayScale < 0.001f)
        {
#if UNITY_5
            gs.rampOffset = 0;
#else
            gs.grayAmount = 0;
#endif
            gs.enabled = false;
        }
        else
        {
            gs.enabled = true;
#if UNITY_5
            gs.rampOffset = GrayScale;
#else
            gs.grayAmount = GrayScale;
#endif
        }
        if (bf == null)
        {
            return;
        }
        if (bf.enabled)
        {
#if UNITY_5
            bf.bloomThreshold = BlurThreshold;
#else
            bf.bloomThreshhold = BlurThreshold;
#endif
        }
    }