void OnSetDistance(float distance) { for (int i = 0; i < targets.Length; i++) { SplinePositioner positioner = (SplinePositioner)targets[i]; double travel = positioner.Travel(0.0, distance, Spline.Direction.Forward); positioner.position = travel; } }
protected override void BodyGUI() { EditorGUILayout.Space(); EditorGUILayout.LabelField("Positioning", EditorStyles.boldLabel); serializedObject.Update(); SerializedProperty mode = serializedObject.FindProperty("_mode"); EditorGUI.BeginChangeCheck(); SplinePositioner positioner = (SplinePositioner)target; EditorGUILayout.PropertyField(mode, new GUIContent("Mode")); if (positioner.mode == SplinePositioner.Mode.Distance) { positioner.position = EditorGUILayout.FloatField("Distance", (float)positioner.position); } else { SerializedProperty percent = serializedObject.FindProperty("_result").FindPropertyRelative("percent"); EditorGUILayout.BeginHorizontal(); SerializedProperty position = serializedObject.FindProperty("_position"); double pos = positioner.ClipPercent(percent.floatValue); EditorGUI.BeginChangeCheck(); pos = EditorGUILayout.Slider("Percent", (float)pos, 0f, 1f); if (EditorGUI.EndChangeCheck()) { position.floatValue = (float)pos; } if (GUILayout.Button("Set Distance", GUILayout.Width(85))) { DistanceWindow w = EditorWindow.GetWindow <DistanceWindow>(true); w.Init(OnSetDistance, positioner.CalculateLength()); } EditorGUILayout.EndHorizontal(); } SerializedProperty targetObject = serializedObject.FindProperty("_targetObject"); EditorGUILayout.PropertyField(targetObject, new GUIContent("Target Object")); if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); } base.BodyGUI(); }
//Take Method from Song Manager, put it here //parent everything to the plane's local transform; //translate/rotate to be part of LevelParent cylinder public void PropogateTrack(Track track, SplineComputer splineComp) { notes = track.notes; for (int i = 0; i < notes.Length; i++) { //Need to set the position to a 0-1 scale for use with spline positioner //NOTE - not necessary with spline component //float zPos = notes[i].beatTime * SongManager.instance.levelScale + SongManager.instance.levelOffset; //Vector3 newBlockPosition = new Vector3(0f, 0f, zPos); double songPercent = (double)(notes[i].gameTime) / (SongManager.instance.LastNoteTime); float angle = trackIndex * 2f * Mathf.PI / SongManager.instance.CurrentSong.tracks.Length; //Debug.Log(angle); GameObject newBlock; switch (notes[i].name) { case "C2": //kick //top block /* * newBlock = Instantiate(levelPrefab, Vector3.zero, Quaternion.identity); * * * * //Vector3 newPos = new Vector3(newBlock.transform.position.x, 4f, zPos); * Vector3 newScale = new Vector3(4f, notes[i].velocity * 2f, 0.75f); * //newBlock.transform.position = newPos; * newBlock.transform.localScale = newScale; * * SplinePositioner sPositioner = newBlock.GetComponent<SplinePositioner>(); * sPositioner.computer = splineComp; * * sPositioner.motion.offset = new Vector2(Mathf.Sin(angle) * SongManager.instance.tubeRadius, Mathf.Cos(angle) * SongManager.instance.tubeRadius); * sPositioner.motion.rotationOffset = new Vector3(0f, 0f, -Mathf.Rad2Deg * angle ); * sPositioner.SetPercent(songPercent); * * * newBlock.transform.SetParent(transform); * newBlock.GetComponent<Renderer>().material = kickMaterial; */ Vector3 newScale; SplinePositioner sPositioner; //stomp pad (connected to evaluator) ///Vector3 stompPos = new Vector3(newBlock.transform.position.x, -0.7f, zPos); GameObject newStomp = Instantiate(stomperPrefab, Vector3.zero, Quaternion.identity); newStomp.transform.localScale = new Vector3(2f, 1f, 2f); SplinePositioner stompPositioner = newStomp.GetComponent <SplinePositioner>(); stompPositioner.computer = splineComp; stompPositioner.motion.offset = new Vector2(Mathf.Sin(angle) * SongManager.instance.tubeRadius, Mathf.Cos(angle) * SongManager.instance.tubeRadius); stompPositioner.motion.rotationOffset = new Vector3(0f, 0f, -Mathf.Rad2Deg * angle); stompPositioner.SetPercent(songPercent); //newStomp.transform.SetParent(transform); notes[i].go = newStomp; break; case "D2": //SNARE OBJECT newBlock = Instantiate(snareBlockPrefab, Vector3.zero, Quaternion.identity); //newPos = new Vector3(newBlock.transform.position.x, 0f, zPos); newScale = new Vector3(4f, notes[i].velocity * 3f, 1.25f); //newBlock.transform.position = newPos; newBlock.transform.localScale = newScale; //Set Block's position along the spline (based on it's % in the song loop) //Adjust rotation accordingly sPositioner = newBlock.GetComponent <SplinePositioner>(); sPositioner.computer = splineComp; sPositioner.motion.offset = new Vector2(Mathf.Sin(angle) * SongManager.instance.tubeRadius, Mathf.Cos(angle) * SongManager.instance.tubeRadius); sPositioner.motion.rotationOffset = new Vector3(0f, 0f, -Mathf.Rad2Deg * angle); sPositioner.SetPercent(songPercent); newBlock.transform.SetParent(transform); newBlock.GetComponent <Renderer>().material = snareMaterial; notes[i].go = newBlock; break; case "F2": //low tom, doesn't work on current controller /* * newBlock = Instantiate(levelPrefab, Vector3.zero, Quaternion.identity); * //newPos = new Vector3(-2.5f, 0f, zPos); * newScale = new Vector3(2f, 5f, 1f); * //newBlock.transform.position = newPos; * newBlock.transform.localScale = newScale; * * sPositioner = newBlock.GetComponent<SplinePositioner>(); * sPositioner.computer = splineComp; * sPositioner.motion.offset = new Vector2(Mathf.Sin(angle) * SongManager.instance.tubeRadius, Mathf.Cos(angle) * SongManager.instance.tubeRadius); * sPositioner.motion.rotationOffset = new Vector3(0f, 0f, -Mathf.Rad2Deg * angle); * sPositioner.SetPercent(songPercent); * * newBlock.transform.SetParent(transform); * newBlock.GetComponent<Renderer>().material = lTomMaterial; * notes[i].go = newBlock; */ break; case "F#2": /* * newBlock = Instantiate(levelPrefab, Vector3.zero, Quaternion.identity); * //newPos = new Vector3(0f, 0f, zPos); * newScale = new Vector3(3f, 0.5f, 0.5f); * * sPositioner = newBlock.GetComponent<SplinePositioner>(); * sPositioner.computer = splineComp; * * sPositioner.motion.offset = new Vector2(Mathf.Sin(angle) * SongManager.instance.tubeRadius, Mathf.Cos(angle) * SongManager.instance.tubeRadius); * sPositioner.motion.rotationOffset = new Vector3(0f, 0f, -Mathf.Rad2Deg * angle); * sPositioner.SetPercent(songPercent); * * //newBlock.transform.position = newPos; * newBlock.transform.localScale = newScale; * newBlock.transform.SetParent(transform); * newBlock.GetComponent<Renderer>().material = hiHatMaterial; * notes[i].go = newBlock; * //hi hat */ break; case "A2": /* * newBlock = Instantiate(levelPrefab, Vector3.zero, Quaternion.identity); * //newPos = new Vector3(0f, 0f, zPos); * newScale = new Vector3(3f, 5f, 0.75f); * //newBlock.transform.position = newPos; * newBlock.transform.localScale = newScale; * * sPositioner = newBlock.GetComponent<SplinePositioner>(); * sPositioner.computer = splineComp; * sPositioner.motion.offset = new Vector2(Mathf.Sin(angle) * SongManager.instance.tubeRadius, Mathf.Cos(angle) * SongManager.instance.tubeRadius); * sPositioner.motion.rotationOffset = new Vector3(0f, 0f, -Mathf.Rad2Deg * angle); * sPositioner.SetPercent(songPercent); * * newBlock.transform.SetParent(transform); * newBlock.GetComponent<Renderer>().material = hTomMaterial; * notes[i].go = newBlock; * //hi tom */ break; } } }