void OnClickOkPoint() { // string assetPath = Application.dataPath; if (null != animFrames && 0 != animFrames.Count) { RelAnimControl animCtrl = Selection.activeGameObject.GetComponent <RelAnimControl>() as RelAnimControl; if (null == animCtrl) { bool isOk = EditorUtility.DisplayDialog("Warning", "Your select gameObject has no attach a RelAnimControl.cs, will auto attach it?", "Ok", "Cancel"); if (isOk) { animCtrl = Selection.activeGameObject.AddComponent <RelAnimControl>() as RelAnimControl; } else { Close(); return; } } animCtrl.origPos = startPostion; animCtrl.keyFrameInfos = new AnimKeyFrameInfo[animFrames.Count]; animFrames.ToArray().CopyTo(animCtrl.keyFrameInfos, 0); } SaveSettings(); Close(); }
/// <summary> /// Replaces the model subfunction /// </summary> /// <param name='_prefabName'> /// _prefab name. /// </param> /// <param name='_originalModel'> /// _original model. /// </param> private void ReplaceModel(string _prefabName, GameObject _originalModel, ResourceMgr.ResourceDelegate dele = null) { if (Globals.Instance.MResourceManager == null) { return; } Globals.Instance.MResourceManager.Load(_prefabName, delegate(Object obj, string error) { if (obj == null) { Debug.LogError("obj == null ReplaceModel " + error); return; } GameObject t_warship = (GameObject)Instantiate(obj); try{ RelAnimControl t_src = _originalModel.GetComponent <RelAnimControl>(); RelAnimControl t_dst = t_warship.AddComponent <RelAnimControl>(); t_src.CopyTo(t_dst); t_dst.transform.parent = _originalModel.transform.parent; t_dst.transform.localPosition = _originalModel.transform.localPosition; Destroy(_originalModel); if (dele != null) { dele(t_warship, error); } }catch (System.Exception ex) { Debug.LogError("ReplaceModel error: " + ex.Message); } }); }
// Response when user click the "AddPoint" Button void OnClickThisPoint() { if (null == Selection.activeGameObject) { EditorUtility.DisplayDialog("Warning", "Please selection your target gameObject.", "Ok"); return; } Transform tf = Selection.activeGameObject.transform; // Debug.Log("" + tf.position); // Debug.Log("" + tf.rotation.eulerAngles); AnimKeyFrameInfo frame = new AnimKeyFrameInfo(); frame.Position = absoluteAnim ? tf.position : tf.position - startPostion; Vector3 tempAngles = absoluteAnim ? tf.rotation.eulerAngles : tf.rotation.eulerAngles - startEulerAngles; tempAngles.x %= 360; tempAngles.y %= 360; tempAngles.z %= 360; frame.EulerAngles = tempAngles; frame.TransformTime = 1.0f; frame.DelayTime = 0.0f; if (currGameObj != Selection.activeGameObject) { animFrames.Clear(); currGameObj = Selection.activeGameObject; RelAnimControl animCtrl = currGameObj.GetComponent <RelAnimControl>() as RelAnimControl; if (null == animCtrl || null == animCtrl.keyFrameInfos || 0 == animCtrl.keyFrameInfos.Length) { animFrames = new List <AnimKeyFrameInfo>(); animFrames.Capacity = 5; } else { animFrames = new List <AnimKeyFrameInfo>(); animFrames.Capacity = animCtrl.keyFrameInfos.Length + 5; foreach (AnimKeyFrameInfo info in animCtrl.keyFrameInfos) { animFrames.Add(info); } } animFrames.Add(frame); } else { animFrames.Add(frame); } needUpdateFrames = true; }
void Update() { bool tPlayDone = HelpUtil.GetButtonState(false); // some tap event to stop cutscene if (tPlayDone && m_currCameraAnimControl != null) { m_currCameraAnimControl.Stop(true); Destroy(m_currCameraAnimControl); m_currCameraAnimControl = null; } }
internal void GetSelectionInfo() { if (null == Selection.activeGameObject) { return; } RelAnimControl animCtrl = Selection.activeGameObject.GetComponent <RelAnimControl>() as RelAnimControl; if (null != animCtrl) { animFrames.Capacity = animCtrl.keyFrameInfos.Length + 5; foreach (AnimKeyFrameInfo info in animCtrl.keyFrameInfos) { animFrames.Add(info); } } }
/// <summary> /// tzz added for /// Copies to other RelAnimControl /// </summary> /// <param name='_dst'> /// _dst. /// </param> public void CopyTo(RelAnimControl _dst) { _dst.keyFrameInfos = keyFrameInfos; _dst.origPos = origPos; _dst.origEulerAngles = origEulerAngles; }
void Start() { float tEndMoveTime = 0; // remove the main camera of its child GameObject t_tmpCamera = transform.Find("Tmp Camera").gameObject; if (t_tmpCamera != null) { mStoreMainCamera = GameObject.FindWithTag("MainCamera"); if (mStoreMainCamera == null) { mStoreMainCamera = Globals.Instance.MSceneManager.mMainCamera.gameObject; } mStoreMainCamera.transform.parent = t_tmpCamera.transform.parent; mStoreMainCamera.transform.localPosition = t_tmpCamera.transform.localPosition; mStoreMainCamera.transform.rotation = t_tmpCamera.transform.rotation; RelAnimControl t_src = t_tmpCamera.GetComponent <RelAnimControl>(); RelAnimControl t_dst = mStoreMainCamera.AddComponent <RelAnimControl>(); t_src.CopyTo(t_dst); DestroyObject(t_tmpCamera); m_currCameraAnimControl = t_dst; m_currCameraAnimControl.SetPlayAnimDoneDelegate(delegate(){ if (m_playOverDelegate != null) { try{ m_playOverDelegate(this); }catch (System.Exception e) { Debug.LogError(e.GetType().Name + " " + e.Message); } } // destroy own Destroy(this); // SceneFadeInOut.Instance.FadeInScene(5); }); tEndMoveTime = m_currCameraAnimControl.GetPlayLength(); if (tEndMoveTime > 0) { StartCoroutine(EndCutsceneMove(tEndMoveTime)); } } // replace the model int t_num = Mathf.Min(m_replaceDst.Length, m_replaceSrc.Length); for (int i = 0; i < t_num; i++) { if (m_replaceDst[i].ToLower() == "actor") { ReplaceActor(m_replaceSrc[i]); } else if (m_replaceDst[i].ToLower() == "boss") { ReplaceBoss(m_replaceSrc[i]); } } // get the cutscene background position if (smTopCutscene == null && Globals.Instance.MGUIManager != null) { smTopCutscene = Globals.Instance.MGUIManager.MGUICamera.transform.Find("CutsceneTop").gameObject; smBottomCutscene = Globals.Instance.MGUIManager.MGUICamera.transform.Find("CutsceneBottom").gameObject; PackedSprite ps = smTopCutscene.GetComponent <PackedSprite>(); smTopCutscenePos[0] = new Vector3(0, Screen.height / 2, smTopCutscene.transform.localPosition.z); smBottomCutscenePos[0] = new Vector3(0, -Screen.height / 2, smTopCutscene.transform.localPosition.z); smTopCutscenePos[1] = smTopCutscenePos[0] + new Vector3(0, CUT_SCENE_MOVE_HEIGHT, 0); smBottomCutscenePos[1] = smBottomCutscenePos[0] + new Vector3(0, -CUT_SCENE_MOVE_HEIGHT, 0); } if (tEndMoveTime > 0) { // setup the animation of cutscene background smTopCutscene.transform.localPosition = smTopCutscenePos[1]; smBottomCutscene.transform.localPosition = smBottomCutscenePos[1]; iTween.MoveTo(smTopCutscene, iTween.Hash("position", smTopCutscenePos[0], "time", CUT_SCENE_MOVE_LENGTH, "isLocal", true)); iTween.MoveTo(smBottomCutscene, iTween.Hash("position", smBottomCutscenePos[0], "time", CUT_SCENE_MOVE_LENGTH, "isLocal", true)); } // set the uiCamera cull mask to default/LargeObject in order to // hide the all interface and show the cutscene background // defualt layer is cutscene background // LargeObject layer is fadeInOut backgroud Globals.Instance.MGUIManager.MGUICamera.cullingMask = (1 << 0) | (1 << 11); // disable the UIManager for POINTER_PTR evente; }