private void ReadAllAudioList() { //m_allAudioNames = new List<string>(); m_allAudioNames = JsonSerializationHelper.ReadJsonList <string>(GetStreamingAssetsRootPath() + "/AudioTrackList.json"); //foreach (var name in m_allAudioNames) //{ // print("Load audio track: " + name); //} }
private void DrawButtons() { EditorGUI.BeginChangeCheck(); m_manipulateMode = (ManipulationMode)EditorGUILayout.EnumPopup( "Mode to manipulate node", m_manipulateMode); if (EditorGUI.EndChangeCheck()) { PlayerPrefs.SetInt("Editor_ManipulateMode", (int)m_manipulateMode); SceneView.RepaintAll(); } EditorGUI.BeginChangeCheck(); m_drawPathInEditor = GUILayout.Toggle(m_drawPathInEditor, "Draw path in Editor", GUILayout.Width(Screen.width)); if (EditorGUI.EndChangeCheck()) { PlayerPrefs.SetInt("Editor_DrawPath", m_drawPathInEditor ? 1 : 0); } EditorGUI.BeginChangeCheck(); m_autoSmooth = GUILayout.Toggle(m_autoSmooth, "Smooth another handle in the BezierPoint", GUILayout.Width(Screen.width)); if (EditorGUI.EndChangeCheck()) { PlayerPrefs.SetInt("Editor_AutoSmooth", m_autoSmooth ? 1 : 0); } isAutoConnectProperty.boolValue = GUILayout.Toggle(isAutoConnectProperty.boolValue, "Connect first and last nodes?", GUILayout.Width(Screen.width)); drawDebugPathProperty.boolValue = GUILayout.Toggle(drawDebugPathProperty.boolValue, "Use LineRenderer to draw path in game?", GUILayout.Width(Screen.width)); if (GUILayout.Button(addPointContent)) { Undo.RecordObject(Target, "Added a waypoint"); BezierPoint point = new BezierPoint( Vector3.zero, Quaternion.identity, true);; Target.AddPoint(point); if (Target.Points.Count > 1) { Vector3 dir = -SceneView.lastActiveSceneView.camera.transform.right; if (Target.Points.Count > 2) { Vector3 prevDir = (Target.Points[Target.Points.Count - 2].Position - Target.Points[Target.Points.Count - 3].Position); dir *= prevDir.magnitude; if (Vector3.Dot(prevDir, dir) < 0) { dir *= -1; } } Target.SetAnchorPosition(Target.Points.Count - 1, Target.Points[Target.Points.Count - 2].Position + dir); Target.SetAnchorRotation(Target.Points.Count - 1, Quaternion.LookRotation(dir)); } SceneView.RepaintAll(); } if (GUILayout.Button(clearAllPointsContent)) { //TODO: Use Target.RemoveAll() later Target.Points.Clear(); SceneView.RepaintAll(); } if (GUILayout.Button(savePathData)) { string savePath = EditorUtility.SaveFilePanel( "Save path into file", Application.dataPath, Target.name, "json"); if (savePath.Length != 0) { JsonSerializationHelper.WriteJsonList <BezierPoint>(savePath, Target.Points); } } if (GUILayout.Button(loadPathData)) { // Simple version //string loadPath = EditorUtility.OpenFilePanel( // "Load path from file", // Application.dataPath, // "json,*"); // More customized string loadPath = EditorUtility.OpenFilePanelWithFilters( "Load path from file", Application.dataPath, new string[] { "Json files", "json", "All files", "*" }); if (loadPath.Length != 0) { Target.SetPoints(JsonSerializationHelper.ReadJsonList <BezierPoint>(loadPath)); } Target.UpdateAnchorTransforms(); SceneView.RepaintAll(); } GUILayout.Space(10); }