private void LoadValue(string name, object value) { try { switch (name) { case "name": SceneName = Convert.ToString(value); break; case "duration": Duration = Convert.ToSingle(value); break; case "fadein": FadeIn = Convert.ToSingle(value); break; case "fadeout": FadeOut = Convert.ToSingle(value); break; case "campath": { JsonList list = (JsonList)value; for (int i = 0; i < list.Count - 2; i += 3) { CameraPath.Add(new Vector3( Convert.ToSingle(list[i + 0]), Convert.ToSingle(list[i + 1]), Convert.ToSingle(list[i + 2]) )); } } break; } } catch (Exception e) { Debug.Log($"Slide property \"{name}\" cannot hold a value of type \"{value.GetType().Name}\"!"); Debug.LogException(e); } }
// private float _previewCamFov; private void OnEnable() { _animator = (CameraPathAnimator)target; _cameraPath = _animator.GetComponent <CameraPath>(); _colouredText = new GUIStyle(); _colouredText.normal.textColor = _cameraPath.textColour; }
static bool ValidateAlignPathPointtoView() { GameObject selected = Selection.activeGameObject; if (selected == null) { return(false); } CameraPath camPath = selected.GetComponent <CameraPath>(); if (camPath == null) { return(false); } switch (camPath.pointMode) { case CameraPath.PointModes.ControlPoints: return(true); case CameraPath.PointModes.Transform: return(true); case CameraPath.PointModes.Orientations: return(true); default: return(false); } }
void ResourceListener(AssetPtr ptr) { if (ptr == null || ptr.Data == null) { return; } if (!ptr.Data.url.Contains(mCurnAnimatorame)) { return; } GameObject cameraanimator = new GameObject(mCurnAnimatorame); CameraPath cPath = cameraanimator.AddComponent <CameraPath>(); CameraPathAnimator animator = cameraanimator.AddComponent <CameraPathAnimator>(); XmlDocument xml = new XmlDocument(); xml.LoadXml(ptr.Data.text); cPath.FromXML(xml); if (Camera.main != null) { animator.animationObject = Camera.main.transform; } BaseScene scene = SceneManager.Instance.GetCurScene(); if (scene != null) { animator.AnimationCustomEvent += scene.GetCameraPathManager().OnCustomEvent; animator.AnimationFinishedEvent += animator_AnimationFinishedEvent; } FollowAnimator = animator; animator.Play(); }
public void Clear() { mAnimatorPath = null; mFollowPath = null; LockCamera = false; mCurnAnimatorame = null; }
public override void Init(CameraPath _cameraPath) { if (initialised) return; pointTypeName = "Speed"; base.Init(_cameraPath); }
public void SetControlCamera(GameObject camera, CameraPathAnimator animator) { mFollowPath = null; if (animator != null) { mFollowPath = animator.cameraPath; } mCameraObj = camera; mCameraTest = mCameraObj.GetComponent <CameraTest>(); if (mCameraTest == null) { mCameraTest = mCameraObj.AddComponent <CameraTest>(); } mCamera = mCameraObj.GetComponent <Camera>(); mCameraTransform = mCameraObj.transform; mCameraObj.GetComponent <AudioListener>().enabled = false; int layer2DUI = LayerMask.NameToLayer("2D UI"); int layer3DUI = LayerMask.NameToLayer("3D UI"); int layerPreview = LayerMask.NameToLayer("UIPreview"); int layerMask = (1 << layer2DUI) | (1 << layer3DUI) | (1 << layerPreview); int oldCullingMask = mCamera.cullingMask; mCamera.cullingMask = oldCullingMask & (~layerMask); }
public virtual void FromXML(XmlNode node, CameraPath cameraPath) { if (node["customName"].HasChildNodes) { customName = node["customName"].FirstChild.Value; } index = int.Parse(node["index"].FirstChild.Value); positionModes = (PositionModes)System.Enum.Parse(typeof(PositionModes), node["positionModes"].FirstChild.Value); if (node["point"] != null) { point = cameraPath[int.Parse(node["point"].FirstChild.Value)]; } if (node["cpointA"] != null) { cpointA = cameraPath[int.Parse(node["cpointA"].FirstChild.Value)]; } if (node["cpointB"] != null) { cpointB = cameraPath[int.Parse(node["cpointB"].FirstChild.Value)]; } _percent = float.Parse(node["_percent"].FirstChild.Value); _animationPercentage = float.Parse(node["_animationPercentage"].FirstChild.Value); curvePercentage = float.Parse(node["curvePercentage"].FirstChild.Value); worldPosition.x = float.Parse(node["worldPositionX"].FirstChild.Value); worldPosition.y = float.Parse(node["worldPositionY"].FirstChild.Value); worldPosition.z = float.Parse(node["worldPositionZ"].FirstChild.Value); lockPoint = bool.Parse(node["lockPoint"].FirstChild.Value); }
public ModifyPositionKnotCommand(CameraPath path, KnotDescriptor knotDesc, float endSpeed, Vector3 endForward_GS, bool mergesWithCreateCommand = false, bool final = false, BaseCommand parent = null) : base((CameraPathPositionKnot)knotDesc.knot, mergesWithCreateCommand, parent) { m_Path = path; m_EndSpeed = endSpeed; m_KnotIndex = knotDesc.positionKnotIndex.Value; m_Final = final; // Store the local space rotation because the knot's parent (the canvas) may change // between undo/redos. m_EndRotation_CS = Quaternion.Inverse(App.Scene.Pose.rotation) * Quaternion.LookRotation(endForward_GS); m_StartRotation_CS = Knot.transform.localRotation; m_StartSpeed = Knot.TangentMagnitude; // Cache our dance partner if the path loops and we're an end knot. if (m_Path.PathLoops) { if (m_KnotIndex == 0 || m_KnotIndex == m_Path.NumPositionKnots - 1) { m_PartnerKnotIndex = (m_KnotIndex == 0) ? (m_Path.NumPositionKnots - 1) : 0; m_KnotLoopPartner = m_Path.PositionKnots[m_PartnerKnotIndex]; m_PartnerStartRotation_CS = m_KnotLoopPartner.transform.localRotation; m_PartnerStartSpeed = m_KnotLoopPartner.TangentMagnitude; } } }
private void UpdateCalculations() { animators = FindObjectsOfType <CameraPathAnimator>(); int numberOfPaths = animators.Length; pathTimes = new float[numberOfPaths]; // percentages = new Dictionary<int, float[]>(); for (int p = 0; p < numberOfPaths; p++) { CameraPathAnimator animator = animators[p]; CameraPath path = animator.cameraPath; float pathStoredResoltion = path.storedPointResolution; int storedPointsSize = path.storedValueArraySize; float pathTime = 0; for (int i = 0; i < storedPointsSize; i++) { float pathSpeed = animator.pathSpeed; if (path.speedList.listEnabled) { float perc = pathStoredResoltion * i; pathSpeed = path.GetPathSpeed(perc); } pathTime += pathStoredResoltion / pathSpeed; } pathTimes[p] = pathTime; // percentages.Add(); } }
public override RgbColor OnCameraHit(CameraPath path, RNG rng, int pixelIndex, Ray ray, SurfacePoint hit, float pdfFromAncestor, RgbColor throughput, int depth, float toAncestorJacobian) { RgbColor value = RgbColor.Black; // Was a light hit? Emitter light = scene.QueryEmitter(hit); if (light != null) { value += throughput * OnEmitterHit(light, hit, ray, path, toAncestorJacobian); } // Perform connections if the maximum depth has not yet been reached if (depth < MaxDepth) { if (EnableConnections) { value += throughput * BidirConnections(pixelIndex, hit, -ray.Direction, rng, path, toAncestorJacobian); } var nextEvtSum = RgbColor.Black; var nextEvtSumSqr = RgbColor.Black; for (int i = 0; i < NumShadowRays; ++i) { var c = throughput * PerformNextEventEstimation(ray, hit, rng, path, toAncestorJacobian); nextEvtSum += c; nextEvtSumSqr += c * c; value += c; } } return(value); }
CameraPath ComputePath(Vector3 Start, Vector3 End, Vector3 Focus) { CameraPath Path = new CameraPath(); Path.Next = Start; // Figure out what portals we want CameraGraphPortalNode StartNode = Graph.GetClosestPortal(Start); CameraGraphPortalNode EndNode = Graph.GetClosestPortal(End); CameraGraphSphereNode FocusEdge = Graph.GetClosestSphere(Focus); // A* that shit! List <CameraGraphPortalNode> PortalPath = GetPortalPath(StartNode, EndNode, FocusEdge); // Get the points as positions foreach (CameraGraphPortalNode Portal in PortalPath) { Path.Points.Enqueue(Portal.transform.position); } // Finally, add the endpoint to the back of the queue Path.Points.Enqueue(End); return(Path); }
public static void ImportCameraPath() { string filefolder = PlayerPrefs.GetString("camerapath"); if (!Directory.Exists(filefolder)) { return; } string path = EditorUtility.OpenFilePanel("打开摄像机文件", filefolder, "xml"); string filename = Path.GetFileNameWithoutExtension(path); string[] arr = filename.Split(new string[] { "_^_^_" }, StringSplitOptions.None); if (arr.Length != 2) { EditorUtility.DisplayDialog("提示", "打开文件错误", "确定"); return; } GameObject newCameraPath = new GameObject(arr[1]); Undo.RegisterCreatedObjectUndo(newCameraPath, "Import Camera Path"); CameraPath cPath = newCameraPath.AddComponent <CameraPath>(); CameraPathAnimator animator = newCameraPath.AddComponent <CameraPathAnimator>(); cPath.FromXML(path); if (Camera.main != null) { animator.animationObject = Camera.main.transform; } Selection.objects = new Object[] { newCameraPath }; SceneView.lastActiveSceneView.FrameSelected(); EditorUtility.SetDirty(newCameraPath); }
//public virtual void FromXML(XmlNode node, CameraPath cameraPath) //{ // if (node["customName"].HasChildNodes) // customName = node["customName"].FirstChild.Value; // index = int.Parse(node["index"].FirstChild.Value); // positionModes = (PositionModes)System.Enum.Parse(typeof(PositionModes), node["positionModes"].FirstChild.Value); // if (node["point"] != null) // point = cameraPath[int.Parse(node["point"].FirstChild.Value)]; // if (node["cpointA"] != null) // cpointA = cameraPath[int.Parse(node["cpointA"].FirstChild.Value)]; // if (node["cpointB"] != null) // cpointB = cameraPath[int.Parse(node["cpointB"].FirstChild.Value)]; // _percent = float.Parse(node["_percent"].FirstChild.Value); // _animationPercentage = float.Parse(node["_animationPercentage"].FirstChild.Value); // curvePercentage = float.Parse(node["curvePercentage"].FirstChild.Value); // worldPosition.x = float.Parse(node["worldPositionX"].FirstChild.Value); // worldPosition.y = float.Parse(node["worldPositionY"].FirstChild.Value); // worldPosition.z = float.Parse(node["worldPositionZ"].FirstChild.Value); // lockPoint = bool.Parse(node["lockPoint"].FirstChild.Value); //} public virtual void FromXML(XMLNode node, CameraPath cameraPath) { if (node.GetValue("customName>0>_text") != null) { customName = node.GetValue("customName>0>_text"); } index = int.Parse(node.GetValue("index>0>_text")); positionModes = (PositionModes)System.Enum.Parse(typeof(PositionModes), node.GetValue("positionModes>0>_text")); if (node.GetValue("point>0>_text") != null) { point = cameraPath[int.Parse(node.GetValue("point>0>_text"))]; } if (node.GetValue("cpointA>0>_text") != null) { cpointA = cameraPath[int.Parse(node.GetValue("cpointA>0>_text"))]; } if (node.GetValue("cpointB>0>_text") != null) { cpointB = cameraPath[int.Parse(node.GetValue("cpointB>0>_text"))]; } _percent = float.Parse(node.GetValue("_percent>0>_text")); _animationPercentage = float.Parse(node.GetValue("_animationPercentage>0>_text")); curvePercentage = float.Parse(node.GetValue("curvePercentage>0>_text")); worldPosition.x = float.Parse(node.GetValue("worldPositionX>0>_text")); worldPosition.y = float.Parse(node.GetValue("worldPositionY>0>_text")); worldPosition.z = float.Parse(node.GetValue("worldPositionZ>0>_text")); lockPoint = bool.Parse(node.GetValue("lockPoint>0>_text")); }
private void SetTransform(Transform transform, CameraPathAnimator animator) { CameraPath path = animator.cameraPath; transform.position = path.GetPathPosition(editorPercentage); transform.rotation = animator.GetAnimatedOrientation(editorPercentage, false); }
public static void AlignPathPoint() { GameObject selected = Selection.activeGameObject; CameraPath camPath = selected.GetComponent <CameraPath>(); CameraPathAnimator animator = selected.GetComponent <CameraPathAnimator>(); Undo.RecordObject(camPath, "Align Camera Path Point to View"); if (camPath != null && animator != null) { switch (animator.orientationMode) { case CameraPathAnimator.orientationModes.custom: if (camPath.pointMode == CameraPath.PointModes.Orientations) { int selectedPoint = camPath.selectedPoint; CameraPathOrientation point = camPath.orientationList[selectedPoint]; Camera sceneCam = SceneView.GetAllSceneCameras()[0]; Quaternion lookRotation = Quaternion.LookRotation(sceneCam.transform.forward); point.rotation = lookRotation; if (point.positionModes == CameraPathPoint.PositionModes.FixedToPoint) { CameraPathControlPoint cPoint = point.point; cPoint.worldPosition = sceneCam.transform.position; } camPath.RecalculateStoredValues(); } if (camPath.pointMode == CameraPath.PointModes.Transform || camPath.pointMode == CameraPath.PointModes.ControlPoints) { int selectedPoint = camPath.selectedPoint; CameraPathControlPoint cPoint = camPath[selectedPoint]; Camera sceneCam = SceneView.GetAllSceneCameras()[0]; cPoint.worldPosition = sceneCam.transform.position; CameraPathOrientation point = (CameraPathOrientation)camPath.orientationList.GetPoint(cPoint); if (point != null) { Quaternion lookRotation = Quaternion.LookRotation(sceneCam.transform.forward); point.rotation = lookRotation; } camPath.RecalculateStoredValues(); } break; default: if (camPath.pointMode == CameraPath.PointModes.Transform || camPath.pointMode == CameraPath.PointModes.ControlPoints) { int selectedPoint = camPath.selectedPoint; CameraPathControlPoint point = camPath[selectedPoint]; Camera sceneCam = SceneView.GetAllSceneCameras()[0]; float forwardArcLength = camPath.StoredArcLength(selectedPoint); point.forwardControlPointLocal = sceneCam.transform.forward * (Mathf.Max(forwardArcLength, 0.1f) * 0.33f); point.worldPosition = sceneCam.transform.position; camPath.RecalculateStoredValues(); } break; } } }
private void OnEnable() { _animator = (CameraPathAnimator)target; _cameraPath = _animator.GetComponent <CameraPath>(); //Preview Camera if (_animator.editorPreview != null) { DestroyImmediate(_animator.editorPreview); } if (CameraPathPreviewSupport.previewSupported) { _animator.editorPreview = new GameObject("Animtation Preview Cam"); _animator.editorPreview.hideFlags = HideFlags.HideAndDontSave; _animator.editorPreview.AddComponent <Camera>(); _animator.editorPreview.GetComponent <Camera>().fieldOfView = 60; _animator.editorPreview.GetComponent <Camera>().depth = -1; //Retreive camera settings from the main camera Camera[] cams = Camera.allCameras; bool sceneHasCamera = cams.Length > 0; Camera sceneCamera = null; Skybox sceneCameraSkybox = null; if (Camera.main) { sceneCamera = Camera.main; } else if (sceneHasCamera) { sceneCamera = cams[0]; } if (sceneCamera != null) { sceneCameraSkybox = sceneCamera.GetComponent <Skybox>(); } if (sceneCamera != null) { _animator.editorPreview.GetComponent <Camera>().backgroundColor = sceneCamera.backgroundColor; if (sceneCameraSkybox != null) { _animator.editorPreview.AddComponent <Skybox>().material = sceneCameraSkybox.material; } else if (RenderSettings.skybox != null) { _animator.editorPreview.AddComponent <Skybox>().material = RenderSettings.skybox; } _animator.editorPreview.GetComponent <Camera>().orthographic = sceneCamera.orthographic; } _animator.editorPreview.GetComponent <Camera>().enabled = false; } if (EditorApplication.isPlaying && _animator.editorPreview != null) { _animator.editorPreview.SetActive(false); } }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); time = float.Parse(node["time"].FirstChild.Value); introStartEasePercentage = float.Parse(node["introStartEasePercentage"].FirstChild.Value); outroEndEasePercentage = float.Parse(node["outroEndEasePercentage"].FirstChild.Value); introCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node["introCurve"]); outroCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node["outroCurve"]); }
public override void Init(CameraPath _cameraPath) { if(initialised) return; base.Init(_cameraPath); cameraPath.PathPointAddedEvent += AddFOV; pointTypeName = "FOV"; initialised = true; }
public override void Init(CameraPath _cameraPath) { if (this.initialised) { return; } this.pointTypeName = "Event"; base.Init(_cameraPath); }
override protected void Awake() { base.Awake(); App.Switchboard.CameraPathModeChanged += OnCameraPathModeChanged; m_PreviewSegment = CameraPath.CreateSegment(null); m_PreviewSegment.renderer.material.color = Color.white; m_Mode = Mode.AddPositionKnot; RefreshMeshVisibility(); }
public override void Init(CameraPath _cameraPath) { if (initialised) { return; } pointTypeName = "Speed"; base.Init(_cameraPath); }
//public override void FromXML(XmlNode node, CameraPath cameraPath) //{ // base.FromXML(node, cameraPath); // time = float.Parse(node["time"].FirstChild.Value); // introStartEasePercentage = float.Parse(node["introStartEasePercentage"].FirstChild.Value); // outroEndEasePercentage = float.Parse(node["outroEndEasePercentage"].FirstChild.Value); // introCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node["introCurve"]); // outroCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node["outroCurve"]); //} public override void FromXML(XMLNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); time = float.Parse(node.GetValue("time>0>_text")); introStartEasePercentage = float.Parse(node.GetValue("introStartEasePercentage>0>_text")); outroEndEasePercentage = float.Parse(node.GetValue("outroEndEasePercentage>0>_text")); introCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node.GetNode("introCurve>0")); outroCurve = XMLVariableConverter.FromXMLtoAnimationCurve(node.GetNode("outroCurve>0")); }
public override void Init(CameraPath _cameraPath) { if (initialised) return; pointTypeName = "Orientation"; base.Init(_cameraPath); cameraPath.PathPointAddedEvent += AddOrientation; initialised = true; }
private void RenderPreviews() { int numberOfPaths = animators.Length; GameObject previewGO = new GameObject(); previewGO.hideFlags = HideFlags.HideAndDontSave; Camera previewCam = previewGO.AddComponent <Camera>(); previewCam.orthographic = Camera.main.orthographic; GUILayout.BeginHorizontal(); for (int p = 0; p < numberOfPaths; p++) { CameraPathAnimator animator = animators[p]; CameraPath path = animator.cameraPath; if (path.realNumberOfPoints < 2 || !animator.showPreview) { continue; } if (CameraPathPreviewSupport.previewSupported && !EditorApplication.isPlaying) { RenderTexture rt = RenderTexture.GetTemporary(previewResolution, Mathf.RoundToInt(previewResolution / aspect), 24, RenderTextureFormat.Default, RenderTextureReadWrite.Default, 1); if (previewCam.orthographic) { previewCam.orthographicSize = path.GetPathOrthographicSize(animator.editorPercentage); } else { previewCam.fieldOfView = path.GetPathFOV(animator.editorPercentage); } SetTransform(previewCam.transform, animator); previewCam.enabled = true; previewCam.targetTexture = rt; previewCam.Render(); previewCam.targetTexture = null; previewCam.enabled = false; GUILayout.BeginVertical(); GUILayout.Label(animator.name); GUILayout.Label(rt, GUILayout.Width(200), GUILayout.Height(150)); GUILayout.EndVertical(); RenderTexture.ReleaseTemporary(rt); } else { string errorMsg = CameraPathPreviewSupport.previewSupportedText; EditorGUILayout.LabelField(errorMsg); } } GUILayout.EndHorizontal(); DestroyImmediate(previewGO); }
public override void Init(CameraPath _cameraPath) { if (this.initialised) { return; } this.pointTypeName = "Orientation"; base.Init(_cameraPath); this.cameraPath.PathPointAddedEvent += new CameraPath.PathPointAddedHandler(this.AddOrientation); this.initialised = true; }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); rotation.x = float.Parse(node["rotationX"].FirstChild.Value); rotation.y = float.Parse(node["rotationY"].FirstChild.Value); rotation.z = float.Parse(node["rotationZ"].FirstChild.Value); rotation.w = float.Parse(node["rotationW"].FirstChild.Value); if (node["lookAt"] != null && node["lookAt"].HasChildNodes) lookAt = GameObject.Find(node["lookAt"].FirstChild.Value).transform; }
public override void Init(CameraPath _cameraPath) { if (initialised) { return; } base.Init(_cameraPath); cameraPath.PathPointAddedEvent += AddTilt; pointTypeName = "Tilt"; initialised = true; }
public MoveConstrainedKnotCommand(CameraPath path, KnotDescriptor knotDesc, Quaternion rot_GS, bool mergesWithCreateCommand = false, bool final = false, BaseCommand parent = null) : base(knotDesc.knot, mergesWithCreateCommand, parent) { m_Path = path; m_EndRotation_CS = Quaternion.Inverse(App.Scene.Pose.rotation) * rot_GS; m_EndT = knotDesc.pathT.Value; m_Final = final; m_StartRotation_CS = Knot.transform.localRotation; m_StartT = Knot.PathT; }
public override void Init(CameraPath _cameraPath) { if (initialised) { return; } pointTypeName = "Orientation"; base.Init(_cameraPath); cameraPath.PathPointAddedEvent += AddOrientation; initialised = true; }
public override float EmitterHitMis(CameraPath cameraPath, float pdfEmit, float pdfNextEvent) { if (cameraPath.Vertices.Count == 2) { // use the actual number of samples for DI (no correlation) return(base.EmitterHitMis(cameraPath, pdfEmit, pdfNextEvent * NumShadowRays)); } else { return(base.EmitterHitMis(cameraPath, pdfEmit, pdfNextEvent)); } }
public override void Init() { _cameraPath = gameObject.GetComponent<CameraPath>(); if (_cameraPath == null) _cameraPath = gameObject.AddComponent<CameraPath>(); _cameraAnimator = gameObject.GetComponent<CameraPathAnimator>(); if (_cameraAnimator == null) { _cameraAnimator = gameObject.AddComponent<CameraPathAnimator>(); _cameraAnimator.playOnStart = false; } }
public void GatherCameraPdfs(CameraPath cameraPath, int lastCameraVertexIdx) { // Gather the pdf values along the camera sub-path for (int i = 0; i < lastCameraVertexIdx; ++i) { PdfsCameraToLight[i] = cameraPath.Vertices[i].PdfFromAncestor; if (i < lastCameraVertexIdx - 1) { PdfsLightToCamera[i] = cameraPath.Vertices[i + 1].PdfToAncestor; } } }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); if (node["FOV"] != null) { FOV = float.Parse(node["FOV"].FirstChild.Value); } if (node["Size"] != null) { Size = float.Parse(node["Size"].FirstChild.Value); } }
public virtual void Init(CameraPath _cameraPath) { if (initialised) return; hideFlags = HideFlags.HideInInspector; cameraPath = _cameraPath; cameraPath.CleanUpListsEvent += CleanUp; cameraPath.RecalculateCurvesEvent += RecalculatePoints; cameraPath.PathPointRemovedEvent += PathPointRemovedEvent; cameraPath.CheckStartPointCullEvent += CheckPointCullEventFromStart; cameraPath.CheckEndPointCullEvent += CheckPointCullEventFromEnd; initialised = true; }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); rotation.x = float.Parse(node["rotationX"].FirstChild.Value); rotation.y = float.Parse(node["rotationY"].FirstChild.Value); rotation.z = float.Parse(node["rotationZ"].FirstChild.Value); rotation.w = float.Parse(node["rotationW"].FirstChild.Value); if (node["lookAt"] != null && node["lookAt"].HasChildNodes) { lookAt = GameObject.Find(node["lookAt"].FirstChild.Value).transform; } }
private void OnEnable() { if(target != null) { _cameraPath = (CameraPath)target; _animator = _cameraPath.GetComponent<CameraPathAnimator>(); } CameraPathEditorSceneGUI._cameraPath = _cameraPath; CameraPathEditorSceneGUI._animator = _animator; CameraPathEditorInspectorGUI._cameraPath = _cameraPath; CameraPathEditorInspectorGUI._animator = _animator; CameraPathEditorInspectorGUI.Setup(); }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); type = (Types)System.Enum.Parse(typeof(Types), node["type"].FirstChild.Value); eventName = node["eventName"].FirstChild.Value; if (node["target"] != null && node["target"].HasChildNodes) target = GameObject.Find(node["target"].FirstChild.Value); if (node["methodName"] != null && node["methodName"].HasChildNodes) methodName = node["methodName"].FirstChild.Value; if (node["methodArgument"] != null && node["methodArgument"].HasChildNodes) methodArgument = node["methodArgument"].FirstChild.Value; argumentType = (ArgumentTypes)System.Enum.Parse(typeof(ArgumentTypes), node["argumentType"].FirstChild.Value); }
private void OnEnable() { _animator = (CameraPathAnimator)target; _cameraPath = _animator.GetComponent<CameraPath>(); //Preview Camera if(_animator.editorPreview != null) DestroyImmediate(_animator.editorPreview); if (CameraPathPreviewSupport.previewSupported) { _animator.editorPreview = new GameObject("Animtation Preview Cam"); _animator.editorPreview.hideFlags = HideFlags.HideAndDontSave; _animator.editorPreview.AddComponent<Camera>(); _animator.editorPreview.GetComponent<Camera>().fieldOfView = 60; _animator.editorPreview.GetComponent<Camera>().depth = -1; //Retreive camera settings from the main camera Camera[] cams = Camera.allCameras; bool sceneHasCamera = cams.Length > 0; Camera sceneCamera = null; Skybox sceneCameraSkybox = null; if(Camera.main) { sceneCamera = Camera.main; } else if(sceneHasCamera) { sceneCamera = cams[0]; } if(sceneCamera != null) sceneCameraSkybox = sceneCamera.GetComponent<Skybox>(); if(sceneCamera != null) { _animator.editorPreview.GetComponent<Camera>().backgroundColor = sceneCamera.backgroundColor; if(sceneCameraSkybox != null) _animator.editorPreview.AddComponent<Skybox>().material = sceneCameraSkybox.material; else if(RenderSettings.skybox != null) _animator.editorPreview.AddComponent<Skybox>().material = RenderSettings.skybox; _animator.editorPreview.GetComponent<Camera>().orthographic = sceneCamera.orthographic; } _animator.editorPreview.GetComponent<Camera>().enabled = false; } if(EditorApplication.isPlaying && _animator.editorPreview != null) _animator.editorPreview.SetActive(false); }
public override void Init(CameraPath _cameraPath) { base.Init(_cameraPath); if(!delayInitialised) { _introPoint = gameObject.AddComponent<CameraPathDelay>();// CreateInstance<CameraPathDelay>(); _introPoint.customName = "Start Point"; _introPoint.hideFlags = HideFlags.HideInInspector; AddPoint(introPoint, 0); _outroPoint = gameObject.AddComponent<CameraPathDelay>();//CreateInstance<CameraPathDelay>(); _outroPoint.customName = "End Point"; _outroPoint.hideFlags = HideFlags.HideInInspector; AddPoint(outroPoint, 1); RecalculatePoints(); delayInitialised = true; } pointTypeName = "Delay"; }
private void OnSceneGUI() { _spline = target as CameraPath; _handleTransform = _spline.transform; _handleRotation = Tools.pivotRotation == PivotRotation.Local ? _handleTransform.rotation : Quaternion.identity; Vector3 p0 = ShowPoint(0); for (int i = 1; i < _spline.ControlPointCount; i += 3) { Vector3 p1 = ShowPoint(i); Vector3 p2 = ShowPoint(i+1); Vector3 p3 = ShowPoint(i+2); Handles.color = Color.gray; Handles.DrawLine(p0, p1); Handles.DrawLine(p2, p3); Handles.DrawBezier(p0, p3, p1, p2, Color.white, null, 2f); p0 = p3; } }
public override void OnInspectorGUI() { _spline = target as CameraPath; _selectedIndex = _spline.GetSelectedPoint(_spline.Time); if (_selectedIndex >= 0 && _spline.IsPathPoint(_selectedIndex)) { _spline.SetPoint(_selectedIndex, _spline.transform.position); _spline.SetRotation(_selectedIndex, _spline.transform.rotation); } EditorGUI.BeginChangeCheck(); _spline.Time = EditorGUILayout.Slider("Time", _spline.Time, 0f, 1f); if (EditorGUI.EndChangeCheck()) { var selection = _spline.GetSelectedPoint(_spline.Time); _selectedIndex = selection; } if (GUILayout.Button("Add Point")) { Undo.RecordObjects(new Object[] { _spline.transform, _spline }, "Add Point"); _spline.AddCurve(); EditorUtility.SetDirty(_spline); } }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); tilt = float.Parse(node["tilt"].FirstChild.Value); }
public virtual void FromXML(XmlNode node, CameraPath cameraPath) { if (node["customName"].HasChildNodes) customName = node["customName"].FirstChild.Value; index = int.Parse(node["index"].FirstChild.Value); positionModes = (PositionModes)System.Enum.Parse(typeof(PositionModes), node["positionModes"].FirstChild.Value); if(node["point"] != null) point = cameraPath[int.Parse(node["point"].FirstChild.Value)]; if (node["cpointA"] != null) cpointA = cameraPath[int.Parse(node["cpointA"].FirstChild.Value)]; if (node["cpointB"] != null) cpointB = cameraPath[int.Parse(node["cpointB"].FirstChild.Value)]; _percent = float.Parse(node["_percent"].FirstChild.Value); _animationPercentage = float.Parse(node["_animationPercentage"].FirstChild.Value); curvePercentage = float.Parse(node["curvePercentage"].FirstChild.Value); worldPosition.x = float.Parse(node["worldPositionX"].FirstChild.Value); worldPosition.y = float.Parse(node["worldPositionY"].FirstChild.Value); worldPosition.z = float.Parse(node["worldPositionZ"].FirstChild.Value); lockPoint = bool.Parse(node["lockPoint"].FirstChild.Value); }
public override void FromXML(XmlNode node, CameraPath cameraPath) { base.FromXML(node, cameraPath); if (node["FOV"] != null) FOV = float.Parse(node["FOV"].FirstChild.Value); if (node["Size"] != null) Size = float.Parse(node["Size"].FirstChild.Value); }
private static void ChangePointMode(CameraPath.PointModes newPointMode) { _pointMode = newPointMode; EditorGUIUtility.hotControl = 0; EditorGUIUtility.keyboardControl = 0; }
/// <summary> /// Import XML data into this camera path overwriting the current data /// </summary> /// <param name="XMLPath">An XML file path</param> public void FromXML(string XMLPath) { Debug.Log("Import Camera Path XML " + XMLPath); XmlDocument xml = new XmlDocument(); using (StreamReader sr = new StreamReader(XMLPath)) { xml.LoadXml(sr.ReadToEnd()); } Vector3 newPosition = new Vector3(); XmlNode cameraPathNode = xml.SelectNodes("camerapath")[0]; newPosition.x = float.Parse(cameraPathNode["positionx"].FirstChild.Value); newPosition.y = float.Parse(cameraPathNode["positiony"].FirstChild.Value); newPosition.z = float.Parse(cameraPathNode["positionz"].FirstChild.Value); transform.position = newPosition; if (cameraPathNode["interpolation"] != null) interpolation = (Interpolation)Enum.Parse(typeof(Interpolation), cameraPathNode["interpolation"].FirstChild.Value); if(cameraPathNode["linkedPath"] != null) { GameObject nextPathInScene = GameObject.Find(cameraPathNode["linkedPath"].FirstChild.Value); if (nextPathInScene != null) _nextPath = nextPathInScene.GetComponent<CameraPath>(); } if(cameraPathNode["looped"] != null) _looped = bool.Parse(cameraPathNode["looped"].FirstChild.Value); _points.Clear(); foreach (XmlNode node in xml.SelectNodes("camerapath/controlpoints/controlpoint")) { CameraPathControlPoint newControlPoint = gameObject.AddComponent<CameraPathControlPoint>();//ScriptableObject.CreateInstance<CameraPathControlPoint>(); newControlPoint.hideFlags = HideFlags.HideInInspector; newControlPoint.FromXML(node); AddPoint(newControlPoint); } gameObject.GetComponent<CameraPathAnimator>().FromXML(xml.SelectNodes("camerapath/animator")[0]); _orientationList.FromXML(xml.SelectNodes("camerapath/Orientations/Orientation")); _tiltList.FromXML(xml.SelectNodes("camerapath/Tilts/Tilt")); _eventList.FromXML(xml.SelectNodes("camerapath/Events/Event")); _fovList.FromXML(xml.SelectNodes("camerapath/FOVs/FOV")); _speedList.FromXML(xml.SelectNodes("camerapath/Speeds/Speed")); _delayList.FromXML(xml.SelectNodes("camerapath/Delays/Delay")); }
private static void CPPointArrayInspector(string title, CameraPathPointList pointList, CameraPath.PointModes deflt, CameraPath.PointModes add, CameraPath.PointModes remove) { EditorGUILayout.Space(); EditorGUILayout.LabelField(title); int numberOfPoints = pointList.realNumberOfPoints; if (numberOfPoints == 0) EditorGUILayout.LabelField("There are no points", redText); CameraPathPoint duplicatePoint = pointList.DuplicatePointCheck(); if (duplicatePoint != null) EditorGUILayout.HelpBox("There are points occuping the same percentage.\n Check " + duplicatePoint.displayName + " thanks.", MessageType.Error); for (int i = 0; i < numberOfPoints; i++) { bool cantDelete = false; bool pointIsSelected = i == selectedPointIndex; EditorGUILayout.BeginHorizontal((pointIsSelected) ? selectedBox : unselectedBox); CameraPathPoint arrayPoint = pointList[i]; EditorGUILayout.BeginHorizontal(); if (arrayPoint.customName == "") EditorGUILayout.LabelField("Point " + i, GUILayout.Width(100)); else EditorGUILayout.LabelField(arrayPoint.customName, GUILayout.Width(100)); float valueTextSize = 120; switch (deflt) { case CameraPath.PointModes.FOV: CameraPathFOV fov = (CameraPathFOV)arrayPoint; fov.FOV = EditorGUILayout.FloatField(fov.FOV, GUILayout.Width(50)); break; case CameraPath.PointModes.Speed: CameraPathSpeed speed = (CameraPathSpeed)arrayPoint; speed.speed = EditorGUILayout.FloatField(speed.speed, GUILayout.Width(50)); break; case CameraPath.PointModes.Delay: CameraPathDelay delay = (CameraPathDelay)arrayPoint; if (delay != _cameraPath.delayList.outroPoint) { delay.time = EditorGUILayout.FloatField(delay.time, GUILayout.Width(50)); EditorGUILayout.LabelField("secs", GUILayout.Width(40)); if (delay != _cameraPath.delayList.introPoint) cantDelete = false; else cantDelete = true; } else { cantDelete = true; } break; case CameraPath.PointModes.Ease: cantDelete = true; break; case CameraPath.PointModes.Orientations: CameraPathOrientation orientation = (CameraPathOrientation)arrayPoint; EditorGUILayout.LabelField(orientation.rotation.eulerAngles.ToString(), GUILayout.Width(valueTextSize)); break; case CameraPath.PointModes.Tilt: CameraPathTilt tilt = (CameraPathTilt)arrayPoint; tilt.tilt = EditorGUILayout.FloatField(tilt.tilt, GUILayout.Width(50)); break; case CameraPath.PointModes.Events: CameraPathEvent point = (CameraPathEvent)arrayPoint; point.type = (CameraPathEvent.Types)EditorGUILayout.EnumPopup(point.type, GUILayout.Width(50)); if (point.type == CameraPathEvent.Types.Broadcast) point.eventName = EditorGUILayout.TextField(point.eventName, GUILayout.Width(120)); else { point.target = (GameObject)EditorGUILayout.ObjectField(point.target, typeof(GameObject), true); point.methodName = EditorGUILayout.TextField(point.methodName, GUILayout.Width(55)); } break; } if (!pointIsSelected) { if (GUILayout.Button("Select", GUILayout.Width(60))) { ChangeSelectedPointIndex(i); GotoScenePoint(arrayPoint.worldPosition); } } else { if (GUILayout.Button("Go to", GUILayout.Width(60))) { GotoScenePoint(arrayPoint.worldPosition); } } if (!cantDelete) { if (GUILayout.Button("Delete", GUILayout.Width(60))) { pointList.RemovePoint(arrayPoint); return; } } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndHorizontal(); } if (deflt == CameraPath.PointModes.Ease || deflt == CameraPath.PointModes.ControlPoints) return; //ADD NEW POINTS EditorGUILayout.BeginVertical("box"); EditorGUI.BeginDisabledGroup(_pointMode != deflt); if (GUILayout.Button("Add Point From Inspector")) AddCPointAtPercent(_cameraPath.addPointAtPercent); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("At Percent", GUILayout.Width(80)); _cameraPath.addPointAtPercent = EditorGUILayout.Slider(_cameraPath.addPointAtPercent, 0, 1); EditorGUILayout.EndHorizontal(); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndVertical(); if (_pointMode != add) { if (GUILayout.Button("Add Points in Scene")) { ChangePointMode(add); } } else { if (GUILayout.Button("Done Adding Points")) { ChangePointMode(deflt); } } EditorGUI.BeginDisabledGroup(numberOfPoints == 0); if (_pointMode != remove) { if (GUILayout.Button("Delete Points in Scene")) { ChangePointMode(remove); } } else { if (GUILayout.Button("Done")) { ChangePointMode(deflt); } } EditorGUI.EndDisabledGroup(); }
public override void Init(CameraPath _cameraPath) { pointTypeName = "Event"; base.Init(_cameraPath); }