// add a new key public void addKey(AMITarget itarget, OnAddKey addCall, int _frame, Camera camera = null,/*int? type = null, Camera camera = null, Color? color = null,*/ AMCameraSwitcherKey keyToClone = null) { foreach(AMCameraSwitcherKey key in keys) { // if key exists on frame, update key if(key.frame == _frame) { if(camera != null) { key.setCamera(itarget, camera); key.type = 0; updateCache(itarget); } return; } } AMCameraSwitcherKey a = addCall(gameObject, typeof(AMCameraSwitcherKey)) as AMCameraSwitcherKey; if(keyToClone) { keyToClone.CopyTo(a); } else { a.type = 0; a.still = !AMTakeData.isProLicense; a.easeType = (int)EaseType.EaseOutSine; } a.frame = _frame; if(camera != null) { a.setCamera(itarget, camera); a.type = 0; } // add a new key keys.Add(a); // update cache updateCache(itarget); }
// add a new key public void addKey(int _frame, Camera camera = null,/*int? type = null, Camera camera = null, Color? color = null,*/ AMCameraSwitcherKey keyToClone = null) { foreach(AMCameraSwitcherKey key in keys) { // if key exists on frame, update key if(key.frame == _frame) { if(camera != null) { key.camera = camera; key.type = 0; updateCache(); } return; } } AMCameraSwitcherKey a = ScriptableObject.CreateInstance<AMCameraSwitcherKey>(); if(keyToClone) { a = (AMCameraSwitcherKey) keyToClone.CreateClone(); } else { a.type = 0; a.still = !AMTake.isProLicense; a.easeType = (int)AMTween.EaseType.easeOutSine; } a.frame = _frame; if(camera != null) { a.camera = camera; a.type = 0; } // add a new key keys.Add (a); // update cache updateCache(); }
public override AMKey CreateClone() { AMCameraSwitcherKey a = ScriptableObject.CreateInstance <AMCameraSwitcherKey>(); a.frame = frame; a.type = type; a.camera = camera; a.color = color; a.cameraFadeType = cameraFadeType; a.cameraFadeParameters = new List <float>(cameraFadeParameters); a.irisShape = irisShape; a.still = still; a.easeType = easeType; a.customEase = new List <float>(customEase); return(a); }
// add a new key public void addKey(int _frame, Camera camera = null, /*int? type = null, Camera camera = null, Color? color = null,*/ AMCameraSwitcherKey keyToClone = null) { foreach (AMCameraSwitcherKey key in keys) { // if key exists on frame, update key if (key.frame == _frame) { if (camera != null) { AMUtil.recordObject(key, "update key"); key.camera = camera; key.type = 0; updateCache(); } return; } } AMUtil.recordObject(this, "add key"); AMCameraSwitcherKey a = ScriptableObject.CreateInstance <AMCameraSwitcherKey>(); if (keyToClone) { a = (AMCameraSwitcherKey)keyToClone.CreateClone(); } else { a.type = 0; a.still = !AMTake.isProLicense; a.easeType = (int)AMTween.EaseType.easeOutSine; } a.frame = _frame; if (camera != null) { a.camera = camera; a.type = 0; } // add a new key keys.Add(a); // update cache updateCache(); }
void appendTrackCode(AMTrack track, ref string code) { string s_init = ""; string s_init_suffix = ""; string s = ""; string objName = "track" + (track.id + 1) + "OBJ"; List <string> init_cameras = new List <string>(); List <string> init_textures = new List <string>(); code += "\n// " + track.name; #region translation if ((track is AMTranslationTrack) && (track as AMTranslationTrack).obj) { code += " (Translation)\n"; if (track.cache.Count <= 0) { return; } // initialize object code += getObjectInitialization("GameObject", objName, (track as AMTranslationTrack).obj.name, aData.codeLanguage, null, null); // set initial position code += getInitialPropertiesFor(aData.codeLanguage, track, objName); #endregion #region rotation } else if ((track is AMRotationTrack) && (track as AMRotationTrack).obj) { code += " (Rotation)\n"; if (track.cache.Count <= 0) { return; } // initialize object code += getObjectInitialization("GameObject", objName, (track as AMRotationTrack).obj.name, aData.codeLanguage, null, null); // set initial rotation code += getInitialPropertiesFor(aData.codeLanguage, track, objName); #endregion #region orientation } else if ((track is AMOrientationTrack) && (track as AMOrientationTrack).obj) { code += " (Orientation)\n"; if (track.cache.Count <= 0) { return; } // initialize object code += getObjectInitialization("GameObject", objName, (track as AMOrientationTrack).obj.name, aData.codeLanguage, null, null); // set initial orientation code += getInitialPropertiesFor(aData.codeLanguage, track, objName); #endregion #region animation } else if ((track is AMAnimationTrack) && (track as AMAnimationTrack).obj) { code += " (Animation)\n"; if (track.cache.Count <= 0) { return; } // initialize object code += getObjectInitialization("GameObject", objName, (track as AMAnimationTrack).obj.name, aData.codeLanguage, null, null); #endregion #region audio } else if ((track is AMAudioTrack) && (track as AMAudioTrack).audioSource) { code += " (Audio)\n"; if (track.cache.Count <= 0) { return; } // initialize object code += getObjectInitialization("AudioSource", objName, (track as AMAudioTrack).audioSource.gameObject.name, aData.codeLanguage, null, null); #endregion #region property } else if ((track is AMPropertyTrack) && (track as AMPropertyTrack).component) { code += " (Property)\n"; if (track.cache.Count <= 0) { return; } // initialize component and MemberInfo (Property or Field) code += getObjectInitialization("Component", objName, (track as AMPropertyTrack).component.gameObject.name, aData.codeLanguage, null, (track as AMPropertyTrack).component.GetType().Name); code += getObjectInitialization((track as AMPropertyTrack).getMemberInfoTypeName(), objName, (track as AMPropertyTrack).component.gameObject.name, aData.codeLanguage, (track as AMPropertyTrack).getTrackType(), (track as AMPropertyTrack).component.GetType().Name); // set initial value code += getInitialPropertiesFor(aData.codeLanguage, track, objName); #endregion #region event } else if ((track is AMEventTrack) && (track as AMEventTrack).obj) { code += " (Event)\n"; if (track.cache.Count <= 0) { return; } // initialize object code += getObjectInitialization("GameObject", objName, (track as AMEventTrack).obj.name, aData.codeLanguage, null, null); #endregion #region camera switcher } else if ((track is AMCameraSwitcherTrack)) { code += " (Camera Switcher)\n"; // all cameras Camera[] csCameras = (track as AMCameraSwitcherTrack).getAllCameras(); if (csCameras.Length > 0) { if (aData.codeLanguage == 0) { code += "Camera[] csCameras = new Camera[]{"; } else { code += "var csCameras = ["; } for (int i = 0; i < csCameras.Length; i++) { init_cameras.Add(getDictionaryValue("GameObject.Find(\"" + csCameras[i].gameObject.name + "\").camera", "csCameras[" + i + "]", null)); code += init_cameras[init_cameras.Count - 1]; //code += "GameObject.Find(\""+csCameras[i].gameObject.name+"\").camera"; if (i <= csCameras.Length - 2) { code += ", "; } } if (aData.codeLanguage == 0) { code += "}"; } else { code += "]"; } code += ";\n"; } // all textures Texture[] csTextures = (track as AMCameraSwitcherTrack).getAllTextures(); if (csTextures.Length > 0) { if (aData.codeLanguage == 0) { code += "Texture[] csTextures = new Texture[]{"; } else { code += "var csTextures = ["; } for (int i = 0; i < csTextures.Length; i++) { init_textures.Add(getDictionaryValue("AMTween.LoadTexture2D(\"" + csTextures[i].name + "\")", "csTextures[" + i + "]", null)); code += init_textures[init_textures.Count - 1]; //code += "GameObject.Find(\""+csCameras[i].gameObject.name+"\").camera"; if (i <= csTextures.Length - 2) { code += ", "; } } if (aData.codeLanguage == 0) { code += "}"; } else { code += "]"; } //code += ";\n"; code += "; // Put Textures in Resources Folder\n"; } // set initial top camera or show color if (track.keys.Count > 0) { AMCameraSwitcherKey cKey = (track.keys[0] as AMCameraSwitcherKey); if (cKey.type == 0) { string strCam = "null /* Missing Camera */"; if (cKey.camera) { strCam = "GameObject.Find(\"" + cKey.camera.gameObject.name + "\").camera"; strCam = getDictionaryValue(strCam, null, null); } code += "AMTween.SetTopCamera(" + strCam + ", csCameras); // Set Initial Camera\n"; } else { if (aData.codeLanguage == 0) { code += "AMTween.ShowColor(new Color(" + cKey.color.r + "f, " + cKey.color.g + "f, " + cKey.color.b + "f, " + cKey.color.a + "f));"; } else { code += "AMTween.ShowColor(Color(" + cKey.color.r + ", " + cKey.color.g + ", " + cKey.color.b + ", " + cKey.color.a + "));"; } code += " // Set Initial Color\n"; } } } else { code += "\n// Missing Track Object\n"; if (track.cache.Count <= 0) { return; } } #endregion #region action foreach (AMAction action in track.cache) { string actionString; // if audioclip resource, use variable name in ToString if (action is AMAudioAction) { actionString = (action as AMAudioAction).ToString(aData.codeLanguage, aData.getCurrentTake().frameRate, objName + "Frame" + action.startFrame); } else if (action is AMEventAction) { actionString = (action as AMEventAction).ToString(aData.codeLanguage, aData.getCurrentTake().frameRate, objName + "Frame" + action.startFrame); } else { actionString = action.ToString(aData.codeLanguage, aData.getCurrentTake().frameRate); } if (action is AMCameraSwitcherAction && actionString != null) { // textures foreach (string _st in init_textures) { //if(numCameras <= 0) break; string prev = actionString; actionString = actionString.Replace(_st, getDictionaryValue(_st, null, null)); if (prev != actionString) { break; // found one texture, break. Change if a single CameraSwitcherAction can have more than one texture } } // cameras int numCameras = 0; if ((action as AMCameraSwitcherAction).startTargetType == 0) { numCameras++; } if ((action as AMCameraSwitcherAction).endTargetType == 0) { numCameras++; } foreach (string _sc in init_cameras) { if (numCameras <= 0) { break; } string prev = actionString; actionString = actionString.Replace(_sc, getDictionaryValue(_sc, null, null)); if (prev != actionString) { numCameras--; } } } if (actionString != null) { s += actionString; s += "\n"; // resource if (action is AMAudioAction) { s_init += getObjectInitialization("AudioClip", objName + "Frame" + action.startFrame, (action as AMAudioAction).audioClip.name, aData.codeLanguage, null, null); } // method info if ((action is AMEventAction) && !(action as AMEventAction).useSendMessage) { string[] event_init = getMethodInfoInitialization((action as AMEventAction).component, (action as AMEventAction).methodName, objName + "Frame" + action.startFrame, aData.codeLanguage); s_init += event_init[0] + "\n"; // add component init s_init_suffix += event_init[1] + "\n"; // add methodinfo init to suffix } } } #endregion s = s_init + s_init_suffix + s; code += s; code = code.Replace("obj.gameObject", objName); code = code.Replace("obj.memberinfo", objName + "Property"); }
public AMPlugCameraSwitcher(AMCameraSwitcherKey camSwitcher, int frameRate, AMITarget itarget, Camera[] allCameras) : base(null, false) { mCamSwitcher = camSwitcher; mFrameRate = frameRate; mITarget = itarget; mAllCams = allCameras; }
//private float[] mFadeParams; public void Apply(AMCameraSwitcherKey camSwitcher, int frameRate, AMITarget itarget, Camera[] allCameras, bool backwards) { if(mCamSwitcher != camSwitcher) { mCamSwitcher = camSwitcher; float[] fadeParams = mCamSwitcher.cameraFadeParameters.ToArray(); mIsReversed = AMUtil.isTransitionReversed(mCamSwitcher.type, fadeParams); mCam = mCamSwitcher.getCamera(itarget); mCamEnd = mCamSwitcher.getCameraEnd(itarget); mAllCams = allCameras; if(mCamSwitcher.cameraFadeType == (int)Fade.None) { mCamSwitcher.CameraFadeNoneTargets(mCamSwitcher.typeEnd, mCamSwitcher.colorEnd, mCamEnd, mAllCams); mCamSwitcher.CameraEnd(mIsReversed, mCam, mCamEnd, mAllCams); } else { mCamSwitcher.CameraGenerateFadeTargets(mIsReversed, mCam, mCamEnd, mAllCams, fadeParams); } } mBackwards = backwards; }
public void setCameraEnd(AMCameraSwitcherKey nextKey) { _cameraEnd = nextKey._camera; _cameraEndPath = nextKey._cameraPath; }
// 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; } } } }
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); } }
private void previewCameraFade(AMITarget itarget, float frame, AMCameraSwitcherKey action) { // if transition is None, show end camera / color if(action.cameraFadeType == (int)AMCameraSwitcherKey.Fade.None) { // reset camera fade if visible // camera if(action.typeEnd == 0) { Camera endCam = action.getCameraEnd(itarget); if(endCam) AMUtil.SetTopCamera(endCam, GetCachedCameras(itarget)); AMCameraFade.reset(); } else { showColor(action.colorEnd); } return; } // Get camerafade AMCameraFade cf = AMCameraFade.getCameraFade(); cf.isReset = false; bool isReversed = action.isReversed(); int firstTargetType = (isReversed ? action.typeEnd : action.type); int secondTargetType = (isReversed ? action.type : action.typeEnd); // Set render texture or colors if render texture is used setRenderTexture(itarget, cf, frame, firstTargetType, secondTargetType, isReversed, action); setColors(cf, firstTargetType, secondTargetType, isReversed, action); if(cf.irisShape != action.irisShape) cf.irisShape = action.irisShape; cf.mode = action.cameraFadeType; cf.setupMaterials(); cf.r = action.cameraFadeParameters.ToArray(); float percentage = (float)(frame-action.frame)/(float)(action.endFrame-action.frame); float value; // calculate and set value if(action.hasCustomEase()) { value = AMUtil.EaseCustom(1.0f, -1.0f, percentage, action.easeCurve); } else { TweenDelegate.EaseFunc ease = AMUtil.GetEasingFunction((EaseType)action.easeType); value = ease(percentage, 1.0f, -1.0f, 1.0f, action.amplitude, action.period); } cf.value = value; cf.percent = percentage; }
void OnDisable() { window = null; justSet = false; key = null; track = null; aData = null; }
public void reloadAnimatorData() { aData = null; loadAnimatorData(); AMTake take = aData.getCurrentTake(); // update references for track and key bool shouldClose = true; foreach(AMTrack _track in take.trackValues) { if(track == _track) { track = _track; foreach(AMCameraSwitcherKey _key in track.keys) { if(key == _key) { key = _key; shouldClose = false; } } } } if(shouldClose) this.Close(); }
public static void setValues(AMCameraSwitcherKey _key, AMTrack _track) { justSet = true; key = _key; track = _track; selectedTransition = key.cameraFadeType; parameters = new List<float>(key.cameraFadeParameters); irisShape = key.irisShape; }
public static void setDefaultParametersForKey(ref AMCameraSwitcherKey cKey) { Vector2 temp = new Vector2(0f,0f); setDefaultParametersFor(cKey.cameraFadeType, ref cKey.cameraFadeParameters, ref cKey.irisShape, ref temp); }