// Start is called before the first frame update void Start() { NavMeshAgent = this.GetComponent <NavMeshAgent>(); SceneRoot = GameObject.FindObjectOfType <CaptainsChairSceneRoot>(); CamOffset = Camera.main.transform.position - this.transform.position; CameraDefaultRot = Camera.main.transform.localRotation; ToggleMovementBlocked(false); Flythrough = Camera.main.GetComponent <Flythrough>(); /* * GameObject[] objs = GameObject.FindGameObjectsWithTag("Floor"); * foreach (GameObject o in objs) o.GetComponent<MeshRenderer>().enabled = false; * objs = GameObject.FindGameObjectsWithTag("Wall"); * foreach (GameObject o in objs) o.GetComponent<MeshRenderer>().enabled = false;*/ }
public void LoadFlythroughs(string path) { //var path = Application.dataPath; //path += "/../Data/RecordedFlythroughs/record1.json"; // I think this will not work when I run this from build //var str = File.ReadAllText(path); TextAsset targetFile = Resources.Load <TextAsset>(path); var str = targetFile.text; var loadedFlythroughs = JsonConvert.DeserializeObject <List <FlythroughSerializable> >(str); recordedFlythroughs.Clear(); RecordedFlythroughsDropdown.ClearOptions(); foreach (var flythrough in loadedFlythroughs) { var loadedFlythrough = new Flythrough(flythrough.name, flythrough.startTime); loadedFlythrough.CameraInitialPosition = new Vector3(flythrough.cameraInitialPosition.x, flythrough.cameraInitialPosition.y, flythrough.cameraInitialPosition.z); loadedFlythrough.CameraInitialRotation = new Quaternion(flythrough.cameraInitialRotation.x, flythrough.cameraInitialRotation.y, flythrough.cameraInitialRotation.z, flythrough.cameraInitialRotation.w); foreach (var action in flythrough.recordedActions) { var loadedAction = new RecordedEvent(); loadedAction.cameraPosition = new Vector3(action.cameraPosition.x, action.cameraPosition.y, action.cameraPosition.z); loadedAction.cameraRotation = new Quaternion(action.cameraRotation.x, action.cameraRotation.y, action.cameraRotation.z, action.cameraRotation.w); loadedAction.triggerTime = action.triggerTime; loadedAction.triggeredEvent = new Event() { type = action.triggeredEvent.type, button = action.triggeredEvent.button, delta = new Vector2(action.triggeredEvent.delta.x, action.triggeredEvent.delta.y), mousePosition = new Vector2(action.triggeredEvent.mousePosition.x, action.triggeredEvent.mousePosition.y) }; loadedFlythrough.recordedActions.Add(loadedAction); } recordedFlythroughs.Add(loadedFlythrough); RecordedFlythroughsDropdown.options.Add(new Dropdown.OptionData(flythrough.name)); } }
public void ReplayFlythrough(int whichFlythrough) { eventsTriggeredTimes.Clear(); currentState = RecorderState.Replaying; playbackStartTime = Time.realtimeSinceStartup; Flythrough replayedFlythrough = null; if (recordedFlythroughs.Count > 0) { replayedFlythrough = recordedFlythroughs[whichFlythrough]; } if (replayedFlythrough != null) { currentFlythrough = replayedFlythrough; CameraController.ControlsDisabled = true; CameraController.MainCamera.transform.position = currentFlythrough.CameraInitialPosition; CameraController.MainCamera.transform.rotation = currentFlythrough.CameraInitialRotation; CameraController.transform.position = currentFlythrough.CameraInitialPosition; CameraController.transform.rotation = currentFlythrough.CameraInitialRotation; } }
public void StartReplaying() { //Debug.Log("-------------------------------------------------------------------- Replaying Started"); eventsTriggeredTimes.Clear(); currentState = RecorderState.Replaying; playbackStartTime = Time.realtimeSinceStartup; Flythrough replayedFlythrough = null; if (recordedFlythroughs.Count > 0) { replayedFlythrough = recordedFlythroughs[RecordedFlythroughsDropdown.value]; } if (replayedFlythrough != null) { currentFlythrough = replayedFlythrough; CameraController.ControlsDisabled = true; CameraController.MainCamera.transform.position = currentFlythrough.CameraInitialPosition; CameraController.MainCamera.transform.rotation = currentFlythrough.CameraInitialRotation; CameraController.transform.position = currentFlythrough.CameraInitialPosition; CameraController.transform.rotation = currentFlythrough.CameraInitialRotation; //Debug.Log("Replaying of " + currentFlythrough.Name + " started."); StopButton.interactable = true; PlayButton.interactable = false; RecButton.interactable = false; SaveButton.interactable = false; LoadButton.interactable = false; Color col = replayTimeText.color; col.a = 1; replayTimeText.color = col; } }
// These functions will be called upon certain button clicks public void StartRecording() { //Debug.Log("-------------------------------------------------------------------- Recording Started"); currentFlythrough = new Flythrough("Flythrough " + recordedFlythroughs.Count, Time.realtimeSinceStartup); //currentFlythrough.CameraInitialTransform = CameraController.MainCamera.transform; currentFlythrough.CameraInitialPosition = CameraController.MainCamera.transform.position; currentFlythrough.CameraInitialRotation = CameraController.MainCamera.transform.rotation; RecButton.interactable = false; StopButton.interactable = true; SaveButton.interactable = false; LoadButton.interactable = false; PlayButton.interactable = false; Color col = replayTimeText.color; col.a = 1; replayTimeText.color = col; replayTimeText.text = "Recording..." + currentFlythrough.Name; currentState = RecorderState.Recording; }