ball testing

This commit is contained in:
2024-10-13 16:13:44 +05:30
parent 7822aec907
commit a9f605b732
39 changed files with 28126 additions and 576 deletions

View File

@@ -7,7 +7,8 @@ using UnityEngine.Networking;
public class LoadFromPrep : MonoBehaviour
{
public AudioSource source;
public PredictiveMover mover;
public Mover mover;
public List<float> allHits;
void Awake(){
if(PrepConnector.saveLoadData == null){
@@ -19,7 +20,8 @@ public class LoadFromPrep : MonoBehaviour
void Start(){
if(PrepConnector.saveLoadData != null){
StartCoroutine(LoadAudioCoroutine(PrepConnector.saveLoadData.musicFile));
mover.allHits = PrepConnector.saveLoadData.hits;
allHits = PrepConnector.saveLoadData.hits;
mover.SetHits(allHits);
PlayerPrefs.SetString("saveData", JsonUtility.ToJson(PrepConnector.saveLoadData));
PlayerPrefs.Save();
}
@@ -29,7 +31,7 @@ public class LoadFromPrep : MonoBehaviour
{
string filePath = Path.Combine(Application.persistentDataPath, fileName);
string url = "file://" + filePath;
Debug.Log("Loading file from " + url);
UnityWebRequest www = UnityWebRequestMultimedia.GetAudioClip(url, AudioType.WAV); // Use AudioType.MPEG for MP3 files
yield return www.SendWebRequest();

View File

@@ -9,8 +9,11 @@ public class PrepConnector : MonoBehaviour
public static SaveLoadData saveLoadData;
public void LoadPlay(){
Time.timeScale = 1f;
SaveLoadPrep.instance.Save();
saveLoadData = SaveLoadPrep.instance.saveLoadData;
PlayerPrefs.DeleteKey("prep_data");
PlayerPrefs.Save();
SceneManager.LoadScene("Runner");
}

View File

@@ -17,6 +17,7 @@ public class PrepController : MonoBehaviour
public Button removePinBtn;
public Toggle followSeekerToggle;
public TMP_Text playbackTimeTxt;
public TMP_Text hitCountTxt;
public static List<GameObject> markers = new List<GameObject>();
public static void Reset(){
@@ -30,10 +31,38 @@ public class PrepController : MonoBehaviour
removePinBtn.onClick.AddListener(RemoveMarker);
instance = this;
Screen.orientation = ScreenOrientation.LandscapeLeft;
}
void Update()
{
if(Input.GetKeyDown(KeyCode.RightArrow)){
AddMarker();
}
if(Input.GetKeyDown(KeyCode.LeftArrow)){
float lastTime=0f;
for(int i=0; i < markers.Count; i++){
if(markers[i].GetComponent<Marker>().myTime < source.time){
lastTime = markers[i].GetComponent<Marker>().myTime;
}else{
break;
}
}
Vector3 newCamPos = new Vector3(lastTime * AudioAnalyzer.instance.zoomingYMult, cam.position.y, cam.position.z);
if(source.isPlaying){
TogglePlay();
cam.position = newCamPos;
TogglePlay();
}else{
cam.position = newCamPos;
}
if(Input.GetKey(KeyCode.RightShift)){
RemoveMarker();
}
}
hitCountTxt.text = markers.Count.ToString();
playbackTimeTxt.text = source.time.ToString("n3");
if(followSeekerToggle.isOn){

View File

@@ -25,6 +25,17 @@ public class SaveLoadPrep : MonoBehaviour
saveBtn.onClick.AddListener(Save);
loadBtn.onClick.AddListener(ShowLoadContent);
instance =this;
}
void Start(){
if(PrepConnector.saveLoadData != null){
saveLoadData = PrepConnector.saveLoadData;
Debug.Log("Loading music file at " + saveLoadData.musicFile);
MusicLoader.instance.OnFileSelected(saveLoadData.musicFile, true);
PrepController.instance.SetMarkers(saveLoadData.hits);
}
}

View File

@@ -31,7 +31,7 @@ public class TimescaleAdjuster : MonoBehaviour
if(Time.timeScale > 0.25f){
Time.timeScale -= 0.25f;
}else{
Time.timeScale = 0.1f;
Time.timeScale *= 0.5f;
}
UpdateText();