}// Convert a point in the screen in a Ray for the world public void ChangeState(string stateName, bool hasSmooth) { if (currentState != null && currentState.Name.Equals(stateName) || !isInit) { if (firstStateIsInit) { useSmooth = hasSmooth; } return; } useSmooth = !firstStateIsInit ? startSmooth : hasSmooth; // search for the camera state string name CameraState state = CameraStateList != null?CameraStateList.tpCameraStates.Find(delegate(CameraState obj) { return(obj.Name.Equals(stateName)); }) : new CameraState("Default"); if (state != null) { currentStateName = stateName; currentState.cameraMode = state.cameraMode; lerpState = state; // set the state of transition (lerpstate) to the state finded on the list if (!firstStateIsInit) { currentState.defaultDistance = Vector3.Distance(targetLookAt.position, transform.position); currentState.height = state.height; currentState.fov = state.fov; StartCoroutine(ResetFirstState()); } // in case there is no smooth, a copy will be make without the transition values if (currentState != null && !useSmooth) { currentState.CopyState(state); } } else { // if the state choosed if not real, the first state will be set up as default if (CameraStateList != null && CameraStateList.tpCameraStates.Count > 0) { state = CameraStateList.tpCameraStates[0]; currentStateName = state.Name; currentState.cameraMode = state.cameraMode; lerpState = state; if (currentState != null && !useSmooth) { currentState.CopyState(state); } } } // in case a list of states does not exist, a default state will be created if (currentState == null) { currentState = new CameraState("Null"); currentStateName = currentState.Name; } if (CameraStateList != null) { indexList = CameraStateList.tpCameraStates.IndexOf(state); } currentZoom = state.defaultDistance; if (currentState.cameraMode == TPCameraMode.FixedAngle) { mouseX = currentState.fixedAngle.x; mouseY = currentState.fixedAngle.y; } currentState.fixedAngle = new Vector3(mouseX, mouseY); indexLookPoint = 0; }//Change CameraState