fix playerprefs usage + rename audiobundles

This commit is contained in:
mangorifo
2024-02-04 17:52:19 +08:00
parent b3bb082a6b
commit 4804b2e0e5
12 changed files with 616 additions and 192 deletions
@@ -27,7 +27,6 @@ public class HomeWorld_Initialize : MonoBehaviour
public AssetBundle AudioBundle;
public RectTransform SettingsPanel;
private Resolution GameResolutionPre;
public Toggle FullscreenToggle;
public Toggle PostProcessingToggle;
public SettingsPanel SettingsPanelScript;
@@ -59,16 +58,6 @@ public class HomeWorld_Initialize : MonoBehaviour
}
}*/
if (PlayerPrefs.HasKey("FullscreenState") && FullscreenToggle)
{
if (PlayerPrefs.GetInt("FullscreenState") == 1)
{
FullscreenToggle.isOn = true;
} else
{
FullscreenToggle.isOn = false;
}
}
if (PlayerPrefs.GetInt("PostProcessingEnabled") == 1)
{
+16 -1
View File
@@ -2,6 +2,7 @@ using TMPro;
using UnityEngine;
using System.Collections.Generic;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.UI;
public class SettingsPanel : MonoBehaviour
{
@@ -9,6 +10,7 @@ public class SettingsPanel : MonoBehaviour
public GameObject settingsPanelDeactivator;
public bool DisableSettingsPanelWhenLinkedGameobjectIsActivated = false;
public TMP_Dropdown GraphicsQualityDropdown;
public Toggle FullscreenToggle;
public PostProcessVolume PostProcessVolume;
public List<PostProcessVolume> PostProcessingVolumes = new() { };
@@ -44,7 +46,19 @@ public class SettingsPanel : MonoBehaviour
}
GraphicsQualityDropdown.AddOptions(Options);
GraphicsQualityDropdown.value = QualitySettings.GetQualityLevel();
if (!PlayerPrefs.HasKey("QualityLevel"))
GraphicsQualityDropdown.value = QualitySettings.GetQualityLevel();
else
{
QualitySettings.SetQualityLevel(PlayerPrefs.GetInt("QualityLevel"));
GraphicsQualityDropdown.value = PlayerPrefs.GetInt("QualityLevel");
}
if (PlayerPrefs.HasKey("FullscreenState") && FullscreenToggle)
{
FullscreenToggle.isOn = bool.Parse(PlayerPrefs.GetString("FullscreenState"));
}
}
}
@@ -52,6 +66,7 @@ public class SettingsPanel : MonoBehaviour
{
if (GraphicsQualityDropdown)
{
PlayerPrefs.SetInt("QualityLevel", index);
QualitySettings.SetQualityLevel(index);
}
}
+3 -11
View File
@@ -1,7 +1,6 @@
using System.IO;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
@@ -11,6 +10,7 @@ namespace JTN
{
public bool changeResolutionAutomatically;
public bool useStartupScriptHere;
public Utils UtilsScript;
public TMP_Text MessageText;
[ShowOnly] public int MissingAssetFiles = 0;
public List<string> FilesThatMustExistInStreamingAssetsToSwitchScenes = new List<string>() {
@@ -31,16 +31,8 @@ namespace JTN
else
{
int FullscreenState = PlayerPrefs.GetInt("FullscreenState");
if (FullscreenState == 0)
{
Screen.fullScreenMode = FullScreenMode.Windowed;
Screen.SetResolution(1533, 720, false);
Debug.Log("Changed game resolution to 1533x720");
} else
{
Debug.Log($"Set game resolution to {Screen.currentResolution} (fullscreen)");
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
}
if (PlayerPrefs.HasKey("FullscreenState"))
UtilsScript.SetFullscreen(bool.Parse(PlayerPrefs.GetString("FullscreenState")));
}
}
private void Start()
+14 -26
View File
@@ -11,6 +11,7 @@ namespace JTN
{
public class Utils : MonoBehaviour
{
/*
public bool scrolling;
public GameObject objectRot;
public GameObject sn;
@@ -19,6 +20,7 @@ namespace JTN
private float tm = 0;
private bool once = false;
private GameObject currentObjectRot;
*/
public string GameObjectList;
public bool DestroyParentIfNotDevelopment = false;
@@ -107,34 +109,22 @@ namespace JTN
}
private void Start()
{
if (scrolling)
{
currentObjectRot = Instantiate(objectRot, sn.transform.position, sn.transform.rotation);
}
GameObject[] allObjects = UnityEngine.Object.FindObjectsOfType<GameObject>();
foreach (GameObject go in allObjects)
GameObjectList = GameObjectList + ", " + go.name;
if (!Debug.isDebugBuild || Application.platform != RuntimePlatform.WindowsEditor)
Destroy(Parent);
if (PlayerPrefs.HasKey("QualityLevel"))
QualitySettings.SetQualityLevel(PlayerPrefs.GetInt("QualityLevel"));
if (PlayerPrefs.HasKey("FullscreenState"))
SetFullscreen(bool.Parse(PlayerPrefs.GetString("FullscreenState")));
}
private void FixedUpdate()
{
if (scrolling)
{
if (tm < srate)
{
tm += Time.deltaTime;
}
else if (!once && tm < srate)
{
tm = 0;
currentObjectRot = Instantiate(objectRot, sn.transform.position, sn.transform.rotation);
}
currentObjectRot.GetComponent<RectTransform>().position = currentObjectRot.GetComponent<RectTransform>().position + (Vector3.forward * movespeed) * Time.deltaTime;
once = true;
}
if (LoadSceneOnObjectActivateOrDeactivate && AdvancedLevelManager)
if (RunOnDeactivate)
@@ -179,22 +169,20 @@ namespace JTN
{
obj.SetActive(false);
}
public void SetFullscreen (bool FullscreenState)
public void SetFullscreen(bool FullscreenState)
{
Debug.Log($"Set fullscreen pref to {FullscreenState}");
PlayerPrefs.SetString("FullscreenState", $"{FullscreenState}");
if (FullscreenState)
{
PlayerPrefs.SetInt("FullscreenState", 1);
Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
Screen.SetResolution(1533, 720, false);
}
else
//Screen.fullScreenMode = FullScreenMode.FullScreenWindow;
Screen.SetResolution(1533, 720, true);
} else
{
PlayerPrefs.SetInt("FullscreenState", 0);
Screen.fullScreenMode = FullScreenMode.Windowed;
Screen.SetResolution(1533, 720, false);
}
}
public void DisableAnim(Animation anim)
{