Settings Screen init
This commit is contained in:
26
Assets/Scripts/Menu/infinityUI.cs
Normal file
26
Assets/Scripts/Menu/infinityUI.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class infinityUI : MonoBehaviour
|
||||
{
|
||||
public float speed;
|
||||
public RectTransform panel;
|
||||
public Vector2 curPosition;
|
||||
public Vector2 curSize;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
panel.SetSizeWithCurrentAnchors(RectTransform.Axis.Horizontal, Screen.width * 2);
|
||||
}
|
||||
public float curX;
|
||||
void FixedUpdate()
|
||||
{
|
||||
curX += Time.deltaTime * speed;
|
||||
curPosition = panel.localPosition;
|
||||
curSize = panel.sizeDelta;
|
||||
|
||||
if(curX >= Screen.width) { curX = 0; }
|
||||
panel.anchoredPosition = new Vector2(-curX, 0);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Menu/infinityUI.cs.meta
Normal file
11
Assets/Scripts/Menu/infinityUI.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 196af1a58d52acf448c82c69caf80746
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -7,6 +7,7 @@ using UnityEngine.UI;
|
||||
|
||||
public class menuController : MonoBehaviour
|
||||
{
|
||||
public Text usernameTxt;
|
||||
public GameObject modSelectionPanel;
|
||||
public GameObject serverSelectionPanel;
|
||||
[Header("Server List")]
|
||||
@@ -19,6 +20,15 @@ public class menuController : MonoBehaviour
|
||||
public InputField serverNameInput;
|
||||
void Start()
|
||||
{
|
||||
string[] args = System.Environment.GetCommandLineArgs();
|
||||
for(int i =0; i < args.Length; i++)
|
||||
{
|
||||
string arg = args[i];
|
||||
if(arg.Contains("username"))
|
||||
{
|
||||
usernameTxt.text = args[i + 1];
|
||||
}
|
||||
}
|
||||
if (_LRM == null)
|
||||
{
|
||||
_LRM = (LightReflectiveMirrorTransport)Transport.activeTransport;
|
||||
|
||||
@@ -50,10 +50,15 @@ public class modSelector : MonoBehaviour
|
||||
currentSelectedId = value;
|
||||
NetworkManager.singleton.onlineScene = scenes[value];
|
||||
Bg.sprite = mod_images[value].GetComponent<Image>().sprite;
|
||||
GetComponent<AudioSource>().PlayOneShot(selectionSfx);
|
||||
playSelectedSound();
|
||||
}
|
||||
public void OnPointerExit()
|
||||
{
|
||||
//currentSelectedId = -1;
|
||||
}
|
||||
|
||||
public void playSelectedSound()
|
||||
{
|
||||
GetComponent<AudioSource>().PlayOneShot(selectionSfx);
|
||||
}
|
||||
}
|
||||
|
||||
243
Assets/Scripts/Menu/settings.cs
Normal file
243
Assets/Scripts/Menu/settings.cs
Normal file
@@ -0,0 +1,243 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.Rendering.PostProcessing;
|
||||
using UnityEditor;
|
||||
|
||||
public class settings : MonoBehaviour
|
||||
{
|
||||
public AudioSource audSrc;
|
||||
public GameObject[] settingsSections;
|
||||
public Button[] settingsSectionsBtns;
|
||||
public AudioClip settingsSectionSelectedSFX;
|
||||
public AudioClip settingsChangedSFX;
|
||||
public AudioClip onHoverSfx;
|
||||
|
||||
[Header("Graphics")]
|
||||
public Toggle vsync;
|
||||
public Dropdown shadows;
|
||||
public Dropdown aa;
|
||||
public Dropdown pp;
|
||||
public Dropdown particles;
|
||||
public Dropdown textureQ;
|
||||
public Dropdown lightningQ;
|
||||
|
||||
|
||||
public void show()
|
||||
{
|
||||
gameObject.SetActive(true);
|
||||
}
|
||||
|
||||
public void hide()
|
||||
{
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
|
||||
|
||||
void Start()
|
||||
{
|
||||
DontDestroyOnLoad(gameObject);
|
||||
SettingPage.instance = this;
|
||||
vsync.onValueChanged.AddListener((bool b) => {
|
||||
PlayerPrefs.SetInt("vsync", (b) ? 1 : 0);
|
||||
PlayerPrefs.Save();
|
||||
playSettingsChangedSFX();
|
||||
reloadGraphicSettings();
|
||||
});
|
||||
|
||||
shadows.onValueChanged.AddListener((int option) =>
|
||||
{
|
||||
PlayerPrefs.SetInt("shadows", option);
|
||||
PlayerPrefs.Save();
|
||||
playSettingsChangedSFX();
|
||||
reloadGraphicSettings();
|
||||
});
|
||||
|
||||
aa.onValueChanged.AddListener((int option) =>
|
||||
{
|
||||
PlayerPrefs.SetInt("aa", option);
|
||||
PlayerPrefs.Save();
|
||||
playSettingsChangedSFX();
|
||||
reloadGraphicSettings();
|
||||
});
|
||||
|
||||
pp.onValueChanged.AddListener((int option) =>
|
||||
{
|
||||
PlayerPrefs.SetInt("pp", option);
|
||||
PlayerPrefs.Save();
|
||||
playSettingsChangedSFX();
|
||||
reloadGraphicSettings();
|
||||
});
|
||||
|
||||
particles.onValueChanged.AddListener((int option) =>
|
||||
{
|
||||
PlayerPrefs.SetInt("particles", option);
|
||||
PlayerPrefs.Save();
|
||||
playSettingsChangedSFX();
|
||||
reloadGraphicSettings();
|
||||
});
|
||||
|
||||
textureQ.onValueChanged.AddListener((int option) =>
|
||||
{
|
||||
PlayerPrefs.SetInt("textureQ", option);
|
||||
PlayerPrefs.Save();
|
||||
playSettingsChangedSFX();
|
||||
reloadGraphicSettings();
|
||||
});
|
||||
|
||||
lightningQ.onValueChanged.AddListener((int option) =>
|
||||
{
|
||||
PlayerPrefs.SetInt("lightningQ", option);
|
||||
PlayerPrefs.Save();
|
||||
playSettingsChangedSFX();
|
||||
reloadGraphicSettings();
|
||||
});
|
||||
|
||||
reloadGraphicSettings();
|
||||
|
||||
if (settingsSections.Length != settingsSectionsBtns.Length) { Debug.LogError("IMBALANCED SETTINGS CONFIG!"); }
|
||||
else
|
||||
{
|
||||
for (int i = 0; i < settingsSectionsBtns.Length; i++)
|
||||
{
|
||||
int x = i;
|
||||
settingsSectionsBtns[x].onClick.AddListener(() => { onSettingsSectionClick(x); });
|
||||
}
|
||||
}
|
||||
onSettingsSectionClick(0);
|
||||
}
|
||||
|
||||
|
||||
void onSettingsSectionClick(int i)
|
||||
{
|
||||
Debug.Log("Selected " + i + " button");
|
||||
for (int x = 0; x < settingsSectionsBtns.Length; x++)
|
||||
{
|
||||
settingsSectionsBtns[x].interactable = (x != i);
|
||||
settingsSections[x].SetActive((x == i));
|
||||
}
|
||||
reloadGraphicSettings();
|
||||
audSrc.PlayOneShot(settingsSectionSelectedSFX);
|
||||
}
|
||||
|
||||
void playSettingsChangedSFX()
|
||||
{
|
||||
audSrc.PlayOneShot(settingsChangedSFX);
|
||||
}
|
||||
|
||||
public void OnHoverSFX()
|
||||
{
|
||||
audSrc.PlayOneShot(onHoverSfx);
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
if (Input.GetKeyDown(KeyCode.Escape))
|
||||
{
|
||||
hide();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public void reloadGraphicSettings()
|
||||
{
|
||||
//Read all settings from prefs
|
||||
vsync.isOn = PlayerPrefs.GetInt("vsync") == 1;
|
||||
shadows.value = PlayerPrefs.GetInt("shadows");
|
||||
aa.value = PlayerPrefs.GetInt("aa");
|
||||
pp.value = PlayerPrefs.GetInt("pp");
|
||||
particles.value = PlayerPrefs.GetInt("particles");
|
||||
textureQ.value = PlayerPrefs.GetInt("textureQ");
|
||||
lightningQ.value = PlayerPrefs.GetInt("lightningQ");
|
||||
|
||||
//APPLY EACH
|
||||
QualitySettings.vSyncCount = PlayerPrefs.GetInt("vsync");
|
||||
QualitySettings.softParticles = pp.value == 1;
|
||||
|
||||
switch (shadows.value)
|
||||
{
|
||||
case 0:
|
||||
QualitySettings.shadows = ShadowQuality.All;
|
||||
QualitySettings.shadowResolution = ShadowResolution.VeryHigh;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
QualitySettings.shadows = ShadowQuality.All;
|
||||
QualitySettings.shadowResolution = ShadowResolution.High;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
QualitySettings.shadows = ShadowQuality.HardOnly;
|
||||
QualitySettings.shadowResolution = ShadowResolution.Medium;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
QualitySettings.shadows = ShadowQuality.HardOnly;
|
||||
QualitySettings.shadowResolution = ShadowResolution.Low;
|
||||
break;
|
||||
|
||||
case 4:
|
||||
QualitySettings.shadows = ShadowQuality.Disable;
|
||||
break;
|
||||
}
|
||||
|
||||
switch (aa.value)
|
||||
{
|
||||
case 0:
|
||||
QualitySettings.antiAliasing = 0;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
QualitySettings.antiAliasing = 2;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
QualitySettings.antiAliasing = 4;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
QualitySettings.antiAliasing = 8;
|
||||
break;
|
||||
}
|
||||
|
||||
PostProcessVolume[] volumes = FindObjectsOfType<PostProcessVolume>();
|
||||
switch (pp.value)
|
||||
{
|
||||
|
||||
case 0:
|
||||
foreach (PostProcessVolume vol in volumes)
|
||||
{
|
||||
vol.enabled = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 3:
|
||||
foreach(PostProcessVolume vol in volumes)
|
||||
{
|
||||
vol.enabled = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
QualitySettings.masterTextureLimit = textureQ.value;
|
||||
|
||||
switch (lightningQ.value)
|
||||
{
|
||||
case 0:
|
||||
// PlayerSettings.colorSpace = ColorSpace.Linear;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
// PlayerSettings.colorSpace = ColorSpace.Gamma;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public static class SettingPage
|
||||
{
|
||||
public static settings instance;
|
||||
}
|
||||
11
Assets/Scripts/Menu/settings.cs.meta
Normal file
11
Assets/Scripts/Menu/settings.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4a352f98e088cd443a1e9745de8040bc
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user