void OnDestroy() { if(_tex) { if(renderTextureCamera && renderTextureCamera.targetTexture == _tex) { renderTextureCamera.targetTexture = null; } DestroyImmediate(_tex); } if(_blankTexture) DestroyImmediate(_blankTexture); if(_placeholderTexture) DestroyImmediate(_placeholderTexture); clearScreenTex(); if(_cf == this) _cf = null; }
// set render texture or colors if render texture is used (stills handled in AMTake) private void setRenderTexture(AMITarget itarget, AMCameraFade cf, float frame, int firstTargetType, int secondTargetType, bool isReversed, AMCameraSwitcherKey action) { Camera firstCamera = (isReversed ? action.getCameraEnd(itarget) : action.getCamera(itarget)); Camera secondCamera = (isReversed ? action.getCamera(itarget) : action.getCameraEnd(itarget)); if(isReversed && frame == action.frame) { if(firstTargetType == 0) AMUtil.SetTopCamera(firstCamera, GetCachedCameras(itarget)); } else { if(secondTargetType == 0) AMUtil.SetTopCamera(secondCamera, GetCachedCameras(itarget)); } if(action.still || (firstTargetType != 0 && secondTargetType != 0)) return; bool isPro = AMTakeData.isProLicense; // first target is camera, set render texture if(firstTargetType == 0) { // if should update render texture if(/*!cf.tex ||*/ cf.shouldUpdateRenderTexture || (isPro && (!firstCamera.targetTexture || !cf.isRenderTextureSetupFor(firstCamera)/*|| firstCamera.targetTexture != cf.tex*/))) { if(isPro) { cf.setupRenderTexture(firstCamera); } else { cf.useRenderTexture = false; // show place-holder if non-pro cf.colorTex = Color.white; cf.hasColorTex = false; cf.clearScreenTex(); cf.placeholder = true; } } } }
public static AMCameraFade getCameraFade() { bool preview = !Application.isPlaying; if(_cf) { _cf.preview = preview; return _cf; } AMCameraFade cf = null; GameObject go = GameObject.Find("AMCameraFade"); if(go) { cf = (AMCameraFade)go.GetComponent(typeof(AMCameraFade)); } if(!cf) { go = new GameObject("AMCameraFade", typeof(AMCameraFade)); if(preview) go.hideFlags = HideFlags.DontSave; cf = (AMCameraFade)go.GetComponent(typeof(AMCameraFade)); } _cf = cf; _cf.preview = preview; return _cf; }
private void setColors(AMCameraFade cf, int firstTargetType, int secondTargetType, bool isReversed, AMCameraSwitcherKey action) { //if(firstTargetType != 1 && secondTargetType != 1) return; Color firstColor = (isReversed ? action.colorEnd : action.color); Color secondColor = (isReversed ? action.color : action.colorEnd); if(firstTargetType == 1) { cf.colorTex = firstColor; cf.hasColorTex = true; } else { cf.hasColorTex = false; } if(secondTargetType == 1) { cf.colorBG = secondColor; cf.hasColorBG = true; } else { cf.hasColorBG = false; } // send event to game view to repaint OnGUI if(!Application.isPlaying && (firstTargetType == 1 || secondTargetType == 1)) { cf.transform.position = new Vector3(cf.transform.position.x, cf.transform.position.y, cf.transform.position.z); } }