public override void OnInspectorGUI() { DrawDefaultInspector(); pathManager = target as PathManager; if (GUILayout.Button("Refresh Path")) { Undo.RecordObject(pathManager, "Refresh Path"); pathManager.GetRandomPath(); EditorUtility.SetDirty(pathManager); } if (GUILayout.Button("Re-calculate Spline")) { Undo.RecordObject(pathManager, "Re-calculate Spline"); pathManager.CalculatePathSpline(); EditorUtility.SetDirty(pathManager); } /* * Commenting out since I'm getting rid of tempGate * if (GUILayout.Button("Adjust Final Position")) { * Undo.RecordObject(pathManager, "Adjust Final Position"); * pathManager.CalculatePathSpline(); * pathManager.AdjustFinalPosition(pathManager.tempGate.GetAttackablePosition()); * EditorUtility.SetDirty(pathManager); * } */ }
/// <summary> /// Call after the start node has been assigned /// </summary> public void Setup(Vector3 finalPosition) { pathManager.GetRandomPath(); pathManager.CalculatePathSpline(); pathManager.AdjustFinalPosition(finalPosition); targetTransform.position = pathManager.startNode.transform.position; // Look at the end node. Rough heuristic, will smooth out in a few frames targetTransform.rotation = Quaternion.LookRotation(pathManager.selectedPath[pathManager.selectedPath.Count - 1].transform.position - targetTransform.position, Vector3.up); elapsedPathWalkTime = 0f; isWalkingPath = true; }