Example #1
0
    public void Play()
    {
        if (m_isPlaying)
        {
            Debuger.Log("还没结束就重新播放了");
            Stop();//先结束老的
        }

        //先找到对应的脚本
        m_fx = GetComponent <PostEffectsBase>();
        if (m_fx == null)
        {
            Debuger.Log("没有找到后期处理特效");
            FxDestroy.DoDestroy(this.gameObject);
            return;
        }
        GetComponent <Camera>().enabled = false;//隐藏相机,如果没有隐藏的话
        Type t = m_fx.GetType();

        m_method = t.GetMethod("OnRenderImage", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
        if (m_method == null)
        {
            Debuger.Log("没有找到OnRenderImage方法:{0}", t.Name);
            FxDestroy.DoDestroy(this.gameObject);
            return;
        }

        //添加到相机特效管理器
        Camera c = null;

#if ART_DEBUG
        c = Camera.main;
#else
        c = CameraMgr.instance == null?null:CameraMgr.instance.CurCamera;
#endif
        if (c == null)
        {
            Debuger.LogError("找不到相机");
            FxDestroy.DoDestroy(this.gameObject);
            return;
        }
        CameraFxMgr camFxMgr = c.AddComponentIfNoExist <CameraFxMgr>();
        m_handle = camFxMgr.Add(t.Name, this);

        m_isPlaying   = true;
        m_beginTime   = Util.time;
        m_destroyTime = -1;

        GameObjectPoolObject po = this.AddComponentIfNoExist <GameObjectPoolObject>();
        if (po != null)//为了实现延迟销毁机制,要用到对象池
        {
            po.m_onIngoreDestroy = IngorePoolDestroy;
        }


        foreach (CameraAni a in m_anis)
        {
            a.OnBegin(m_fx);
        }
    }
Example #2
0
    public void OnBegin(PostEffectsBase fx)
    {
        m_state    = enState.init;
        m_lastTime = -1;
        m_isEnd    = false;

        //找到对应的字段
        Type t = fx.GetType();

        m_fieldInfo = t.GetField(m_fieldName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
        if (m_fieldInfo == null)
        {
            m_fieldInfo = t.GetField("m_" + m_fieldName, BindingFlags.IgnoreCase | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);
        }
        if (m_fieldInfo == null)
        {
            Debuger.LogError("找不到字段:{0}", m_fieldName);
        }

        OnUpdateCamera(fx, 0);
    }