//实例化
        protected void InstantiateEffectPrefab(UEffectPrefabParam _effectParam)
        {
            if (_effectParam.EffectRes == null)
            {
                Trace.LogWarning("实例化UI效果类型:" + _effectParam.AttachEffectType + " 失败,资源没加载");
                return;
            }
            //异步没加载完
            if (!_effectParam.EffectRes.isLoadFinish)
            {
                return;
            }

            GameObject newEffect = _effectParam.EffectRes.InstanceMainRes();

            if (newEffect == null)
            {
                Trace.LogWarning("UI特效资源:" + _effectParam.AttachEffectType + " 实例化失败?");
                return;
            }

            UEffectNode uen = newEffect.GetComponent <UEffectNode>();

            if (!uen)
            {
                uen            = newEffect.AddComponent <UEffectNode>();
                uen.EffectType = UEffectType.UET_EffectPrefab;
            }

            uen.NodeParam = _effectParam;
            _effectParam.EffectGameObject = newEffect;
            RegisterEffectPrefabNode(uen, _effectParam.AttachEffectType);
        }
        protected bool CreateMeshEffect(UEffectMeshParam _effectParam)
        {
            UEffectNode node = _effectParam.AttachParent.GetComponent <UEffectNode>();

            if (node == null)
            {
                node            = _effectParam.AttachParent.gameObject.AddComponent <UEffectNode>();
                node.EffectType = UEffectType.UET_EffectMesh;
            }

            var nodeMesh = node.To <UEffectNodeData_Mesh>();

            if (node && nodeMesh != null && _effectParam.MeshObjectList.Count > 0)
            {
                node.UnRegisterEffectNode();

                nodeMesh.MeshRTTSize = _effectParam.RTTSize;
                //node.GetRectTransform.sizeDelta = _effectParam.DisplaySize;

                nodeMesh.EffectMeshCamera.AttachObject     = _effectParam.MeshCamrea.AttachObject;
                nodeMesh.EffectMeshCamera.IsAttachToObject = _effectParam.MeshCamrea.IsAttachToObject;
                nodeMesh.EffectMeshCamera.FOV            = _effectParam.MeshCamrea.FOV;
                nodeMesh.EffectMeshCamera.PositionOffset = _effectParam.MeshCamrea.PositionOffset;
                nodeMesh.EffectMeshCamera.Rotation       = _effectParam.MeshCamrea.Rotation;

                nodeMesh.EffectMeshObjectList.AddRange(_effectParam.MeshObjectList);

                node.RegisterEffectNode();

                _effectParam.MeshCamrea.Camera = nodeMesh.EffectMeshCamera.Camera;
                _effectParam.MeshRenderNode    = node;
            }
            return(true);
        }
        protected bool DestroyPrefabEffect(UEffectPrefabParam _effectParam)
        {
            //删实例
            if (_effectParam.EffectGameObject != null)
            {
                UEffectNode tmpNode = _effectParam.EffectGameObject.GetComponent <UEffectNode>();
                if (tmpNode != null)
                {
                    tmpNode.To <UEffectNodeData_Prefab>().StopEffect();
                    UnRegisterEffectPrefabNode(tmpNode, _effectParam.AttachEffectType);
                }
                _effectParam.EffectRes.DestroyInstanceRes(ref _effectParam.EffectGameObject);
            }


            //删资源
            UEffectDataLoadParam loadParam = null;

            if (m_dicEffectPrefabTypeUsed.TryGetValue(_effectParam.AttachEffectType, out loadParam) && _effectParam.IsDestroyRes)
            {
                if (_effectParam is UEffectPrefabAsyncParam)
                {
                    AssetBundleManager.ReleaseResNodeAsync(this, loadParam.RefferencePrefabResNode, this, true);
                }
                else
                {
                    AssetBundleManager.ReleaseResNode(this, loadParam.RefferencePrefabResNode, true);
                }
                m_dicEffectPrefabTypeUsed.Remove(_effectParam.AttachEffectType);
            }


            return(true);
        }
        protected void ReleaseRT(UEffectNode _nodeRegister)
        {
            //RenderTexture.ReleaseTemporary(_nodeRegister.MeshDisplayImageRTT);
            var _node = _nodeRegister.To <UEffectNodeData_Mesh>();

            if (_nodeRegister.EffectType == UEffectType.UET_EffectMesh && _node != null)
            {
                _node.MeshDisplayImageRTT.Release();
                _node.MeshDisplayImageRTT = null;
            }
        }
        public void RegisterEffectMeshRenderNode(UEffectNode _nodeRegister)
        {
            var _node = _nodeRegister.To <UEffectNodeData_Mesh>();

            if (_nodeRegister.EffectType == UEffectType.UET_EffectMesh && _node != null)
            {
                m_MeshEffectCount++;
                var tmpRT       = GetRT((int)_node.MeshRTTSize.x, (int)_node.MeshRTTSize.y);
                var tmpRTCamera = GetRTCamera(_nodeRegister);
                _node.MeshDisplayImageRTT     = tmpRT;
                _node.EffectMeshCamera.Camera = tmpRTCamera;
            }
        }
        protected void ReleaseRTCamera(UEffectNode _nodeRegister)
        {
            var _node = _nodeRegister.To <UEffectNodeData_Mesh>();

            if (_nodeRegister.EffectType == UEffectType.UET_EffectMesh && _node != null)
            {
                RemoveAndSortCamera(_node.EffectMeshCamera.Camera);
                m_MeshEffectCount--;
                var temp = _node.EffectMeshCamera.Camera.gameObject;
                ResNode.DestroyRes(ref temp);
                _node.EffectMeshCamera.Camera = null;
            }
        }
        //Manager内部调Node的注册方法
        private void RegisterEffectPrefabNode(UEffectNode _nodeRegister, UEffectPrefabType _eType)
        {
            var _node = _nodeRegister.To <UEffectNodeData_Prefab>();

            if (_node != null)
            {
                _node.EffectType         = _eType;
                _node.EffectPrefabTypeID = CalculateEffectPrefabRefID(_eType);

                m_dicEffectPrefabTypeUsed[_eType].RefferenceList.Add(_nodeRegister.gameObject);

                CheckMaxEffectCount(_eType);
            }
        }
        public void UnRegisterEffectPrefabNode(UEffectNode _nodeUnRegister, UEffectPrefabType _eType)
        {
            //有效果实例移除,减一下引用计数
            if (m_dicEffectPrefabTypeUsed.ContainsKey(_eType) && m_dicEffectPrefabTypeUsed[_eType].RefferenceList.Contains(_nodeUnRegister.gameObject))
            {
                m_dicEffectPrefabTypeUsed[_eType].RefferenceList.Remove(_nodeUnRegister.gameObject);
            }
            //如果有延时效果,在计时还没开始就要结束的话也移除下
            int nTimerID = (int)EEffectTimer.EET_Delay * MaxTimerIDCount + _nodeUnRegister.To <UEffectNodeData_Prefab>().EffectPrefabTypeID;

            if (m_dicTimerIDObject.ContainsKey(nTimerID))
            {
                TimerManager.KillTimer(this, nTimerID);
                m_dicTimerIDObject.Remove(nTimerID);
            }
        }
        public void UnRegisterEffectMeshRenderNode(UEffectNode _nodeRegister)
        {
            var _node = _nodeRegister.To <UEffectNodeData_Mesh>();

            if (_nodeRegister.EffectType == UEffectType.UET_EffectMesh && _node != null)
            {
                if (!_node.EffectMeshCamera.IsAttachToObject)
                {
                    RemoveAndSortCamera(_node.EffectMeshCamera.Camera);
                }

                if (_node.MeshDisplayImageRTT != null)
                {
                    ReleaseRT(_nodeRegister);
                }
                if (_node.EffectMeshCamera.Camera != null)
                {
                    ReleaseRTCamera(_nodeRegister);
                }
            }
        }
Exemplo n.º 10
0
        protected Camera GetRTCamera(UEffectNode _nodeRegister)
        {
            if (m_MeshEffectCameraRoot == null)
            {
                m_MeshEffectCameraRoot = new GameObject("UMeshEffectCameraRoot");

                m_MeshEffectCameraRoot.transform.SetPosition(new Vector3(0, 0, 0));
                m_ListMeshEffectCameraGO = new List <Camera>();
            }

            var newCameraGO = new GameObject("UMeshEffectCamera_" + m_MeshEffectCount);
            var newCamera   = newCameraGO.AddComponent <Camera>();

            newCamera.clearFlags      = CameraClearFlags.SolidColor;
            newCamera.backgroundColor = new Color();
            newCamera.cullingMask     = 1 << LayerMask.NameToLayer(Config.LayerUI);
            newCamera.farClipPlane    = 5;

            AddCamera(newCamera);

            return(newCamera);
        }
Exemplo n.º 11
0
 public UEffectNodeData_Mesh(UEffectNode _node) : base(_node)
 {
 }
Exemplo n.º 12
0
 protected override void OnEnable()
 {
     targetEffectNode = target as UEffectNode;
 }
Exemplo n.º 13
0
 public UEffectNodeData_Material(UEffectNode _node) : base(_node)
 {
 }
Exemplo n.º 14
0
 public UEffectNodeData_Prefab(UEffectNode _node) : base(_node)
 {
 }
Exemplo n.º 15
0
 public UEffectNodeData(UEffectNode _node)
 {
     m_EffectNode = _node;
 }