158 lines
5.3 KiB
C#
158 lines
5.3 KiB
C#
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Rendering.PostProcessing;
|
|
using UnityEngine.UI;
|
|
|
|
public class console : MonoBehaviour
|
|
{
|
|
public GameObject UIObj;
|
|
public InputField consoleInput;
|
|
public Text consoleOutput;
|
|
public PostProcessVolume pp;
|
|
public Camera playerCam;
|
|
|
|
//PostProcessingStuff
|
|
Bloom bloom;
|
|
AutoExposure exposure;
|
|
AmbientOcclusion occlusion;
|
|
void Start()
|
|
{
|
|
pp.profile.TryGetSettings(out bloom);
|
|
pp.profile.TryGetSettings(out exposure);
|
|
pp.profile.TryGetSettings(out occlusion);
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.BackQuote))
|
|
{
|
|
bool isActive = !UIObj.activeSelf;
|
|
UIObj.SetActive(isActive);
|
|
consoleInput.interactable = isActive;
|
|
|
|
if (isActive) consoleInput.Select();
|
|
|
|
}
|
|
|
|
if (Input.GetKeyDown(KeyCode.Return))
|
|
{
|
|
OnConsoleSubmit();
|
|
}
|
|
}
|
|
|
|
public void OnConsoleInput(string text)
|
|
{
|
|
//Debug.Log(text);
|
|
}
|
|
|
|
public void OnConsoleSubmit()
|
|
{
|
|
string input = consoleInput.text.ToLower();
|
|
char[] splitChars = { ' ' };
|
|
string[] inputs = input.Split(splitChars, System.StringSplitOptions.RemoveEmptyEntries );
|
|
|
|
try
|
|
{
|
|
switch (inputs[0])
|
|
{
|
|
case "set":
|
|
switch (inputs[1])
|
|
{
|
|
case "fov":
|
|
Camera.main.fieldOfView = int.Parse(inputs[2]);
|
|
println($"<color=yellow>Done, cam fov : {Camera.main.fieldOfView}</color>");
|
|
break;
|
|
|
|
case "bloom":
|
|
switch (inputs[2])
|
|
{
|
|
case "threshold":
|
|
bloom.threshold.value = float.Parse(inputs[3]);
|
|
println($"<color=yellow>Done, bloom threshold at {bloom.threshold.value}</color>");
|
|
break;
|
|
|
|
default:
|
|
bloom.intensity.value = float.Parse(inputs[2]);
|
|
println($"<color=yellow>Done, bloom intensity at {bloom.intensity.value}</color>");
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case "exposure":
|
|
switch (inputs[2])
|
|
{
|
|
case "max":
|
|
exposure.maxLuminance.value = float.Parse(inputs[3]);
|
|
println($"<color=yellow>Done, exposure max at {exposure.maxLuminance.value}</color>");
|
|
break;
|
|
|
|
case "min":
|
|
exposure.minLuminance.value = float.Parse(inputs[3]);
|
|
println($"<color=yellow>Done, exposure min at {exposure.minLuminance.value}</color>");
|
|
break;
|
|
}
|
|
break;
|
|
|
|
case "occlusion":
|
|
switch (inputs[2])
|
|
{
|
|
case "thickness":
|
|
occlusion.thicknessModifier.value = float.Parse(inputs[3]);
|
|
println($"<color=yellow>Done, occlusion thickness at {occlusion.thicknessModifier.value}</color>");
|
|
break;
|
|
|
|
default:
|
|
occlusion.intensity.value = float.Parse(inputs[2]);
|
|
println($"<color=yellow>Done, occlusion intensity at {occlusion.intensity.value}</color>");
|
|
break;
|
|
}
|
|
break;
|
|
|
|
default:
|
|
println("<color=red>Please specify a value to set, are you retarded?</color>");
|
|
break;
|
|
}
|
|
|
|
break;
|
|
|
|
case "help":
|
|
println("Here are the commands you can use");
|
|
println("");
|
|
println("set fov <int>");
|
|
println("set bloom <float>");
|
|
println("set bloom threshold <float>");
|
|
println("set occlusion <float>");
|
|
println("set occlusion threshold <float>");
|
|
println("");
|
|
|
|
break;
|
|
|
|
default:
|
|
println("<color=red>Please enter a valid command</color>");
|
|
break;
|
|
}
|
|
}
|
|
catch(Exception e)
|
|
{
|
|
println($"<color=red>Error : {e.Message}</color>");
|
|
// throw e;
|
|
}
|
|
|
|
consoleInput.text = "";
|
|
}
|
|
|
|
public void print(string input)
|
|
{
|
|
consoleOutput.text += input;
|
|
}
|
|
|
|
public void println(string input)
|
|
{
|
|
consoleOutput.text += input;
|
|
consoleOutput.text += Environment.NewLine;
|
|
}
|
|
}
|