1
0
mirror of synced 2024-11-23 22:30:56 +01:00

added a json configuration file and uWindowCapture configuration

This commit is contained in:
FizzyApple12 2022-06-03 23:24:17 -04:00
parent 287248c0b8
commit 05f52c38a2
12 changed files with 226 additions and 6 deletions

6
.gitignore vendored
View File

@ -60,3 +60,9 @@ crashlytics-build.properties
# WACVR-specific
uWindowCapture.log
# Visual Studio Code cache directory
.vscode/
# Game configuration file
config.json

View File

@ -19642,6 +19642,7 @@ GameObject:
- component: {fileID: 4876933052092147598}
- component: {fileID: 1305037035229797219}
- component: {fileID: 1908947391}
- component: {fileID: 4931218028133408142}
m_Layer: 0
m_Name: Plane
m_TagString: Untagged
@ -26242,6 +26243,18 @@ Transform:
m_Father: {fileID: 543450651832966738}
m_RootOrder: 240
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &4931218028133408142
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2193423312523191491}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 0ca064e37a912ac49a2b617a99d67189, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!23 &4939662662149421075
MeshRenderer:
m_ObjectHideFlags: 0

View File

@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 0de9bd717f0719141be868c495dcf805
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -0,0 +1,107 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System.IO;
public static class JsonConfiguration {
private static bool hasInitialized = false;
private static JObject config;
private static void ensureInitialization() {
if (hasInitialized) return;
loadFile();
hasInitialized = true;
}
private static string getFileName() {
return Application.dataPath + "/../config.json";
}
private static void saveFile() {
File.WriteAllText(getFileName(), config.ToString());
}
private static void loadFile() {
if (File.Exists(getFileName()))
config = JObject.Parse(File.ReadAllText(getFileName()));
else {
config = new JObject();
saveFile();
}
}
public static void DeleteAll() {
ensureInitialization();
config.RemoveAll();
saveFile();
}
public static void DeleteKey(string key) {
ensureInitialization();
config.Remove(key);
saveFile();
}
public static bool HasKey(string key) {
ensureInitialization();
return config.ContainsKey(key);
}
public static void SetBoolean(string key, bool boolean) {
ensureInitialization();
config[key] = boolean;
saveFile();
}
public static void SetString(string key, string text) {
ensureInitialization();
config[key] = text;
saveFile();
}
public static void SetInt(string key, int number) {
ensureInitialization();
config[key] = number;
saveFile();
}
public static void SetDouble(string key, double number) {
ensureInitialization();
config[key] = number;
saveFile();
}
public static bool GetBoolean(string key) {
ensureInitialization();
return config.Value<bool>(key);
}
public static string GetString(string key) {
ensureInitialization();
return config.Value<string>(key);
}
public static int GetInt(string key) {
ensureInitialization();
return config.Value<int>(key);
}
public static double GetDouble(string key) {
ensureInitialization();
return config.Value<double>(key);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1ac3a0e2569fb414f987646d98807ef9
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -37,7 +37,7 @@ public class HeightAdjuster : MonoBehaviour
void Start()
{
if (PlayerPrefs.HasKey("Height")) height = PlayerPrefs.GetFloat("Height");
if (JsonConfiguration.HasKey("Height")) height = JsonConfiguration.GetDouble("Height");
else SaveHeight();
incrementButton.ButtonPressed += StartIncrementing;
@ -82,6 +82,6 @@ public class HeightAdjuster : MonoBehaviour
}
private void SaveHeight() {
PlayerPrefs.SetFloat("Height", (float) height);
JsonConfiguration.SetDouble("Height", height);
}
}

View File

@ -13,10 +13,10 @@ public class PanelThirdPersonButton : MonoBehaviour
void Start()
{
cr = GetComponent<Renderer>();
SetTP(isTP);
if (JsonConfiguration.HasKey("ThirdPerson")) SetTP(JsonConfiguration.GetBoolean("ThirdPerson"));
else SetTP(isTP);
}
private void OnTriggerEnter(Collider other)
@ -31,5 +31,7 @@ public class PanelThirdPersonButton : MonoBehaviour
isTP = state;
cr.material.color = state ? Color.green : Color.red;
tpCamera?.SetActive(state);
JsonConfiguration.SetBoolean("ThirdPerson", state);
}
}

View File

@ -16,7 +16,7 @@ public class SkyboxSwitcher : MonoBehaviour
[SerializeField]
private List<Material> skyboxes;
[SerializeField]
private int currentSkyboxIndex; // should start at 0
private int currentSkyboxIndex = 0;
[Header("Components")]
[SerializeField]
@ -28,6 +28,9 @@ public class SkyboxSwitcher : MonoBehaviour
void Start()
{
if (JsonConfiguration.HasKey("Skybox")) currentSkyboxIndex = JsonConfiguration.GetInt("Skybox");
else SaveSkyboxIndex();
incrementBtn.ButtonPressed += IncrementEvent;
decrementBtn.ButtonPressed += DecrementEvent;
@ -71,6 +74,8 @@ public class SkyboxSwitcher : MonoBehaviour
}
}
}
SetSkybox();
//foreach (var file in hdrFiles) // HDR files -- no way to use by scripting?
//{
// var uwr = UnityWebRequest.Get(file.ToString());
@ -119,7 +124,13 @@ public class SkyboxSwitcher : MonoBehaviour
private void SetSkybox()
{
counterTxt.text = (currentSkyboxIndex + 1).ToString();
if (skyboxes[currentSkyboxIndex] != null)
if (currentSkyboxIndex < skyboxes.Count && skyboxes[currentSkyboxIndex] != null)
RenderSettings.skybox = skyboxes[currentSkyboxIndex];
SaveSkyboxIndex();
}
private void SaveSkyboxIndex()
{
JsonConfiguration.SetInt("Skybox", currentSkyboxIndex);
}
}

View File

@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System.IO;
using System.Runtime.InteropServices;
using System;
using uWindowCapture;
public class UwcConfigurator : MonoBehaviour {
private UwcWindowTexture uwcWindowTexture;
void Start() {
uwcWindowTexture = GetComponent<UwcWindowTexture>();
if (JsonConfiguration.HasKey("CaptureMode")) {
int rawCaptureMode = JsonConfiguration.GetInt("CaptureMode");
if (rawCaptureMode > 3 || rawCaptureMode < 0) {
JsonConfiguration.SetInt("CaptureMode", (int) uwcWindowTexture.captureMode);
} else
uwcWindowTexture.captureMode = (CaptureMode) JsonConfiguration.GetInt("CaptureMode");
} else
JsonConfiguration.SetInt("CaptureMode", (int) uwcWindowTexture.captureMode);
if (JsonConfiguration.HasKey("CaptureFramerate"))
uwcWindowTexture.captureFrameRate = JsonConfiguration.GetInt("CaptureFramerate");
else
JsonConfiguration.SetInt("CaptureFramerate", uwcWindowTexture.captureFrameRate);
}
}

View File

@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 0ca064e37a912ac49a2b617a99d67189
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@ -137,6 +137,8 @@ PlayerSettings:
bundleVersion: 0.1.1
preloadedAssets:
- {fileID: 11400000, guid: 74eeb7429f216ca45a7093c586513e98, type: 2}
- {fileID: -6265376527240436808, guid: 5e2dc0db42cc5b3459a781fecb0b76f9, type: 2}
- {fileID: -6348321304186183749, guid: 6460523340b221f4ea5611d2c011a26c, type: 2}
metroInputSource: 0
wsaTransparentSwapchain: 0
m_HolographicPauseOnTrackingLoss: 1

View File

@ -1,18 +1,37 @@
# WACVR
A VR arcade emulator
## Current stage
- Successfully started the game itself
- Successfully initialized touch
- Successfully send touch signal
- Successfully enabled Freeplay and tested the touch signal in game
## Current issue
- None!
## Quick guide
- Port binding is same as my other repo MaiDXR
- add "[touch] enable=0" to ini file
## Configuration
A ``config.json`` is automatically created in the WACVR root on startup
- ``Skybox``: the current skybox selected for use (Default: 0)
- ``Height``: the offset from default height that the player is moved (Default: 0.0)
- ``ThirdPerson``: whether or not the camera is in third person (Default: true)
- ``CaptureMode``: the method uWindowCapture will use for window capture
- ``0``: PrintScreen
- ``1``: BitBlt
- ``2``: Windows Graphics Capture
- ``3``: Automatic (Recommended, Default)
- ``CaptureFramerate``: the framerate to capture the game at (Default: 60)
## Why this repo now?
I don't have much time and enough skills to make this project by myself. I'm not familiar with Unreal Engine etc. So I want this project to be a community project.