//设置时间缩放,如果是0的话,游戏完全暂停。注意如果没有设置持续时间的话,用完要自己释放 public TimeScaleHandle AddTimeScale(float scale, float duration, int priority = 0) { TimeScaleHandle handle = new TimeScaleHandle(scale, duration); m_timeScale.Add(handle, priority); return(handle); }
//如果durationInvalid=true则直接切 //firstPriority !=-1的话则第一次用这个的优先级,否则用cameraInfo.durationPriority public CameraHandle Add(CameraInfo cameraInfo, bool firstDurationInvalid = false, int firstPriority = -1) { if (!m_cache) { return(null); } //如果是永久镜头,那么不允许叠加多个,这里给之前那个修改下优先级返回就可以了 LinkedListNode <IShareThingHandle> node = m_share.m_handles.First; CameraHandle tempHandle; while (node != null) { tempHandle = node.Value as CameraHandle; if (tempHandle.m_info == cameraInfo && !tempHandle.m_info.isOverAfterDuration) { m_share.Change(tempHandle, firstPriority == -1 ? tempHandle.m_info.durationPriority : firstPriority); //这里如果已经置顶了,那么就不会立即切了,重置下 if (firstDurationInvalid || tempHandle.m_info.isDurationInvalid) { tempHandle.Reset(firstDurationInvalid); } return(tempHandle); } node = node.Next; } //创建一个新的镜头处理器 CameraHandle handle = new CameraHandle(cameraInfo, firstDurationInvalid); m_share.Add(handle, firstPriority == -1 ? cameraInfo.durationPriority : firstPriority); #if !ART_DEBUG if (cameraInfo.lookType == CameraInfo.enLookType.followBehind) { Role t = RoleMgr.instance.GetRoleByRoleId(cameraInfo.targetId); //if (t == null) // Debug.LogError("创建盯住目标点相机时没有找到目标 目标id:" + cameraInfo.targetId); //else if (t != null) { Transform tran = string.IsNullOrEmpty(cameraInfo.bone) ? t.transform: t.transform.Find(cameraInfo.bone); if (tran == null) { Debug.LogError("没有找到相应骨骼点 roleid:" + cameraInfo.targetId + " 骨骼路径:" + cameraInfo.bone); } handle.SetTarget(tran); } } #endif return(handle); }
public CameraHandle Add(string name, CameraFx fx) { CameraHandle handle = new CameraHandle(name, fx, this); ShareThing st = m_fxs.GetNewIfNo(name); st.Add(handle); if (!this.enabled) { this.enabled = true; } return(handle); }
public MaterialHandle Add(MaterialFx fx) { Cache(); Material startMat = null; //获取原始材质 if (fx.m_type == MaterialFx.enType.replace || fx.m_type == MaterialFx.enType.modify) { if (fx.m_matIndex >= m_materials.Count || m_materials[fx.m_matIndex].m_param == null) { Debuger.LogError("找不到对应材质,或者要改变材质的render材质丢失 fx:{0} index:{1}", fx.name, fx.m_matIndex); return(null); } startMat = (Material)m_materials[fx.m_matIndex].m_param; } //创建新材质 Material newMat; if (fx.m_type == MaterialFx.enType.add || fx.m_type == MaterialFx.enType.replace) { if (fx.m_mat == null) { Debuger.LogError("材质没有填 fx:{0} ", fx.name); return(null); } if (fx.m_anis.Count == 0 && (fx.m_type == MaterialFx.enType.add || !fx.m_useOldTex))//不需要渐变的情况下材质不需要复制 { newMat = fx.m_mat; } else { newMat = new Material(fx.m_mat); newMat.name = fx.m_mat.name + "(Clone)"; } } else if (fx.m_type == MaterialFx.enType.modify) { newMat = new Material(startMat); newMat.name = startMat.name + "(Clone)"; } else { Debuger.LogError("未知的类型:{0}", fx.m_type); return(null); } //如果有多个(Clone)后缀,那只保留一下 //if (newMat.name.EndsWith("(Clone)(Clone)")) //newMat.name = newMat.name.Replace("(Clone)", "") + "(Clone)"; //替换新材质的贴图 if (fx.m_useOldTex && startMat != null) { Texture tex; if (startMat.HasProperty("_MainTex")) { tex = startMat.GetTexture("_MainTex"); } else if (startMat.HasProperty("_MainTexAlpha")) { tex = startMat.GetTexture("_MainTexAlpha"); } else { Debuger.LogError("找不到老材质的贴图 fx:{0} index:{1}", fx.name, fx.m_matIndex); return(null); } if (newMat.HasProperty("_MainTex")) { newMat.SetTexture("_MainTex", tex); } else if (newMat.HasProperty("_MainTexAlpha")) { newMat.SetTexture("_MainTexAlpha", tex); } else { Debuger.LogError("找不到新材质的贴图 fx:{0} index:{1}", fx.name, fx.m_matIndex); return(null); } } //添加到共享事物里进行管理 MaterialHandle handle = new MaterialHandle(fx, newMat, this); ShareThing st; int idx; if (fx.m_type == MaterialFx.enType.add) { st = new ShareThing(); st.m_param = null; //原始材质记录下来,在这里没有原始材质 st.m_param2 = false; //表明不是是角色创建的时候就有的材质 m_materials.Add(st); st.Add(handle); idx = m_materials.Count - 1; } else { st = m_materials[fx.m_matIndex]; st.Add(handle); idx = fx.m_matIndex; } //真正把材质放到Render上 bool needChange = handle == st.Get(); if (needChange) { Material[] mats = m_render.sharedMaterials; int length = Mathf.Max(idx + 1, mats.Length); Material[] newMats = new Material[length]; for (int i = 0; i < length; ++i) { if (i == idx) { newMats[i] = newMat; } else { newMats[i] = mats[i]; } } m_render.sharedMaterials = newMats; } return(handle); }