from github
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user