from github
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
//this script stors the selected color to the playerprefs
|
||||
|
||||
public class ColorButton : MonoBehaviour
|
||||
{
|
||||
[SerializeField] Color buttonColor;
|
||||
[SerializeField] GameObject nameInput;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
GetComponent<Image>().color = buttonColor;
|
||||
|
||||
GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
PlayerPrefs.SetFloat("playerColorR", buttonColor.r);
|
||||
PlayerPrefs.SetFloat("playerColorG", buttonColor.g);
|
||||
PlayerPrefs.SetFloat("playerColorB", buttonColor.b);
|
||||
PlayerPrefs.Save();
|
||||
transform.parent.parent.gameObject.SetActive(false);
|
||||
changeScene();
|
||||
});
|
||||
}
|
||||
|
||||
public void changeScene()
|
||||
{
|
||||
//if the name has already been set, change the scene
|
||||
if (nameInput.activeInHierarchy == false)
|
||||
{
|
||||
SceneManager.LoadScene("RoomCreation");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 97f3ea8b8c8a14e4183b81adaafdf9e6
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
//this script stores the input name to the playerprefs
|
||||
|
||||
public class NameInputKeyboard : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private Button enterButton;
|
||||
[SerializeField] private TMP_Text inputText;
|
||||
[SerializeField] private GameObject keyboardObject;
|
||||
[SerializeField] private GameObject colorInput;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
enterButton.onClick.AddListener( () =>
|
||||
{
|
||||
SetName(inputText.text);
|
||||
keyboardObject.SetActive(false);
|
||||
changeScene();
|
||||
});
|
||||
}
|
||||
|
||||
public void SetName(string name)
|
||||
{
|
||||
PlayerPrefs.SetString("playerName", name);
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
public void changeScene()
|
||||
{
|
||||
//if the color has already been select, change the scene
|
||||
if (colorInput.activeInHierarchy == false)
|
||||
{
|
||||
SceneManager.LoadScene("RoomCreation");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 71d94d1bf314c324cacae87c9b4333f4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d59ebf279daff5f47bcf554e7c430c50
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,59 @@
|
||||
using SimpleFileBrowser;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
|
||||
//this script is in the room creation scene and provides functions to load a vrc save files
|
||||
|
||||
public class LoadSafedFiles : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private TMP_Text infoText;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
try
|
||||
{
|
||||
//add click listener to the button
|
||||
GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
OpenObjLoadingDialog();
|
||||
});
|
||||
}
|
||||
catch
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//if a save file is loaded the current client be made a host (server + client)
|
||||
private void InitializeNetworkData(string path)
|
||||
{
|
||||
PlayerPrefs.SetString("path", path);
|
||||
PlayerPrefs.SetString("status", "host");
|
||||
PlayerPrefs.Save();
|
||||
SceneManager.LoadScene("ClassRoom");
|
||||
}
|
||||
|
||||
// see OBJLoader (same logic)
|
||||
private void OpenObjLoadingDialog()
|
||||
{
|
||||
SimpleFileBrowser.FileBrowser.SetFilters(false, new FileBrowser.Filter("VRC", ".vrc"));
|
||||
SimpleFileBrowser.FileBrowser.ShowLoadDialog((path) => { InitializeNetworkData(path[0]); }, () => { }, FileBrowser.PickMode.Files, allowMultiSelection: false, initialPath: "C:\\vrcsaves");
|
||||
GameObject fileExplorerObject = GameObject.Find("SimpleFileBrowserCanvas(Clone)");
|
||||
GameObject mainCameraObj = Camera.main.gameObject;
|
||||
fileExplorerObject.transform.rotation = mainCameraObj.transform.rotation;
|
||||
Vector3 localRot = Quaternion.ToEulerAngles(fileExplorerObject.transform.localRotation);
|
||||
localRot.z = 0;
|
||||
localRot.x = 0;
|
||||
fileExplorerObject.transform.localRotation = Quaternion.EulerAngles(localRot);
|
||||
Vector3 positionVector = mainCameraObj.transform.position + mainCameraObj.transform.forward * 2 - fileExplorerObject.transform.right * 1.25f;
|
||||
positionVector.y = 0;
|
||||
fileExplorerObject.transform.position = positionVector;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 773e43e630b734a4997e658c059bcef7
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,29 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
using UnityEngine.UI;
|
||||
using System.Net;
|
||||
using System.Net.Sockets;
|
||||
|
||||
public class NetworkHostFunction : MonoBehaviour
|
||||
{
|
||||
// Start is called before the first frame update
|
||||
public void Start()
|
||||
{
|
||||
GetComponent<Button>().onClick.AddListener(() =>
|
||||
{
|
||||
setNetworkData();
|
||||
SceneManager.LoadScene("ClassRoom");
|
||||
});
|
||||
}
|
||||
|
||||
//make the current client host (client + server at the same time)
|
||||
public void setNetworkData()
|
||||
{
|
||||
PlayerPrefs.SetString("status", "host");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6b045e4b35c7bdf409d9d593275cce02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using TMPro;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Net.Sockets;
|
||||
|
||||
|
||||
|
||||
public class NetworkJoinFunction : MonoBehaviour
|
||||
|
||||
{
|
||||
[SerializeField] private Button enterButton;
|
||||
[SerializeField] private TMP_Text inputText;
|
||||
|
||||
[SerializeField] private TMP_Text infoText;
|
||||
// Start is called before the first frame update
|
||||
public void Start()
|
||||
{
|
||||
enterButton.onClick.AddListener(() =>
|
||||
{
|
||||
//check if there ip entered is valid
|
||||
//for any reason the keyboard of blackwhale studios creates zero width whitespaces, this must be cleared!
|
||||
//https://en.wikipedia.org/wiki/Zero-width_space
|
||||
if (IsValidIPv4(inputText.text.Replace("\u200B", "")))
|
||||
{
|
||||
setNetworkData(inputText.text);
|
||||
SceneManager.LoadScene("ClassRoom");
|
||||
}
|
||||
else
|
||||
{
|
||||
infoText.text = "Die Eingabe scheint keine valide IPv4-Adresse zu sein.\n Bitte �berpr�fe deine Eingabe und achte drauf, die Zieladresse wie folgt anzugeben \n 127.0.0.1";
|
||||
}
|
||||
});
|
||||
}
|
||||
public bool IsValidIPv4(string ipAddress)
|
||||
{
|
||||
//the pattern that a valid ipv4 must match
|
||||
string pattern = @"^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$";
|
||||
Regex regex = new Regex(pattern);
|
||||
|
||||
return regex.IsMatch(ipAddress);
|
||||
}
|
||||
|
||||
//just make the current client a client (no server/host etc.)
|
||||
public void setNetworkData(string hostadress)
|
||||
{
|
||||
PlayerPrefs.SetString("hostadress", hostadress.Replace("\u200B", ""));
|
||||
PlayerPrefs.SetString("status", "client");
|
||||
PlayerPrefs.Save();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9e2d50b0ef5577f46abdc76e3cda587c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user