void OnSceneGUI() { if (Application.isPlaying) { return; } tpCamera = (vThirdPersonCamera)target; }
void OnSceneGUI() { if (Application.isPlaying) { return; } tpCamera = (vThirdPersonCamera)target; if (tpCamera.gameObject == Selection.activeGameObject) { if (tpCamera.CameraStateList != null && tpCamera.CameraStateList.tpCameraStates != null && tpCamera.CameraStateList.tpCameraStates.Count > 0) { if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].cameraMode != TPCameraMode.FixedPoint) { return; } try { for (int i = 0; i < tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count; i++) { if (indexSelected == i) { Handles.color = Color.blue; tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint = tpCamera.transform.position; tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle = tpCamera.transform.eulerAngles; if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[indexSelected].freeRotation) { Handles.SphereHandleCap(0, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle, Quaternion.identity, 0.5f, EventType.Ignore); } else { Handles.DrawLine(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, tpCamera.target.position); } } else if (Handles.Button(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, Quaternion.identity, 0.5f, 0.3f, Handles.SphereHandleCap)) { indexSelected = i; tpCamera.indexLookPoint = i; tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint; tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].eulerAngle); } Handles.color = Color.white; Handles.Label(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].positionPoint, tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[i].pointName); } } catch { if (tpCamera.indexList > tpCamera.CameraStateList.tpCameraStates.Count - 1) { tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1; } } } } }
IEnumerator Start() { tpCamera = FindObjectOfType <vThirdPersonCamera>(); var collider = GetComponent <Collider>(); if (collider) { collider.isTrigger = true; collider.enabled = false; yield return(new WaitForEndOfFrame()); collider.enabled = true; } }
void OnEnable() { m_Logo = (Texture2D)Resources.Load("tp_camera", typeof(Texture2D)); indexSelected = 0; tpCamera = (vThirdPersonCamera)target; tpCamera.indexLookPoint = 0; if (tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].cameraMode != TPCameraMode.FixedPoint) { return; } if (tpCamera.CameraStateList != null && (tpCamera.indexList < tpCamera.CameraStateList.tpCameraStates.Count) && tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints.Count > 0) { tpCamera.transform.position = tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].positionPoint; tpCamera.transform.rotation = Quaternion.Euler(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList].lookPoints[0].eulerAngle); } }
public override void OnInspectorGUI() { var oldskin = GUI.skin; if (!skin) { skin = Resources.Load("vSkin") as GUISkin; } GUI.skin = skin; tpCamera = (vThirdPersonCamera)target; EditorGUILayout.Space(); GUILayout.BeginVertical("Third Person Camera by Invector", "window"); GUILayout.Label(m_Logo, GUILayout.MaxHeight(25)); GUILayout.Space(5); if (tpCamera.cullingLayer == 0) { EditorGUILayout.Space(); EditorGUILayout.HelpBox("Please assign the Culling Layer to 'Default' ", MessageType.Warning); EditorGUILayout.Space(); } EditorGUILayout.HelpBox("The target will be assign automatically to the current Character when start, check the InitialSetup method on the Motor.", MessageType.Info); GUI.skin = oldskin; base.OnInspectorGUI(); GUI.skin = skin; GUILayout.EndVertical(); GUILayout.BeginVertical("Camera States", "window"); GUILayout.Label(m_Logo, GUILayout.MaxHeight(25)); GUILayout.Space(5); EditorGUILayout.HelpBox("This settings will always load in this List, you can create more List's with different settings for another characters or scenes", MessageType.Info); tpCamera.CameraStateList = (vThirdPersonCameraListData)EditorGUILayout.ObjectField("CameraState List", tpCamera.CameraStateList, typeof(vThirdPersonCameraListData), false); if (tpCamera.CameraStateList == null) { GUILayout.EndVertical(); return; } GUILayout.BeginHorizontal(); if (GUILayout.Button(new GUIContent("New CameraState"))) { if (tpCamera.CameraStateList.tpCameraStates == null) { tpCamera.CameraStateList.tpCameraStates = new List <vThirdPersonCameraState>(); } tpCamera.CameraStateList.tpCameraStates.Add(new vThirdPersonCameraState("New State" + tpCamera.CameraStateList.tpCameraStates.Count)); tpCamera.indexList = tpCamera.CameraStateList.tpCameraStates.Count - 1; } if (GUILayout.Button(new GUIContent("Delete State")) && tpCamera.CameraStateList.tpCameraStates.Count > 1 && tpCamera.indexList != 0) { tpCamera.CameraStateList.tpCameraStates.RemoveAt(tpCamera.indexList); if (tpCamera.indexList - 1 >= 0) { tpCamera.indexList--; } } GUILayout.EndHorizontal(); if (tpCamera.CameraStateList.tpCameraStates.Count > 0) { if (tpCamera.indexList > tpCamera.CameraStateList.tpCameraStates.Count - 1) { tpCamera.indexList = 0; } tpCamera.indexList = EditorGUILayout.Popup("State", tpCamera.indexList, getListName(tpCamera.CameraStateList.tpCameraStates)); StateData(tpCamera.CameraStateList.tpCameraStates[tpCamera.indexList]); } GUILayout.EndVertical(); EditorGUILayout.Space(); if (GUI.changed) { EditorUtility.SetDirty(tpCamera); EditorUtility.SetDirty(tpCamera.CameraStateList); } GUI.skin = oldskin; }
void OnEnable() { m_Logo = (Texture2D)Resources.Load("tp_camera", typeof(Texture2D)); tpCamera = (vThirdPersonCamera)target; tpCamera.indexLookPoint = 0; }