Inputs with Pun2 not working yet (WiP)
This commit is contained in:
parent
0f8d9931e5
commit
f228a44a70
.vsconfig
Assets
Oculus
OurScripts
SharedSpatialAnchors
ThirdParty/Photon/PhotonUnityNetworking/Resources
ProjectSettings
6
.vsconfig
Normal file
6
.vsconfig
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"version": "1.0",
|
||||
"components": [
|
||||
"Microsoft.VisualStudio.Workload.ManagedGame"
|
||||
]
|
||||
}
|
@ -39,5 +39,5 @@ MonoBehaviour:
|
||||
systemSplashScreen: {fileID: 0}
|
||||
systemSplashScreenType: 0
|
||||
_systemLoadingScreenBackground: 0
|
||||
ovrPluginMd5Win64: e2f96821b9509a5aaf6b44cbb176818322193b3113af1adc9e0af028693c38c9
|
||||
ovrPluginMd5Android: b11c9996e5f49cf2c13b34f2f4bb8d16ad9dd1b4f768087f23be43976458361d
|
||||
ovrPluginMd5Win64: e2f96821b9509a5aaf6b44cbb17681838f16294dc8b353245927ecd374ef4ef2
|
||||
ovrPluginMd5Android: b11c9996e5f49cf2c13b34f2f4bb8d16709b89a4a858464e0e3b2e4a1cd2cc19
|
||||
|
@ -3,103 +3,116 @@ using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
using WPM;
|
||||
using Photon.Pun;
|
||||
|
||||
public class GlobeControllerScript : MonoBehaviour
|
||||
public class GlobeControllerScript : MonoBehaviourPun // Inherit from MonoBehaviourPun
|
||||
{
|
||||
|
||||
public DataManager dataManager;
|
||||
|
||||
|
||||
public float rotateSpeed = 10f; // degrees per second
|
||||
public float rotateSpeed; // degrees per second
|
||||
float step;
|
||||
public ColorizeCountriesScript colorizeScript;
|
||||
public int selectedYear = 1991;
|
||||
public GameObject globe;
|
||||
public int selectedYear;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
colorizeScript.map.ToggleCountrySurface("Brazil", true, Color.blue);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
//Test code from g
|
||||
/* if (OVRInput.GetUp(OVRInput.RawButton.Y) || OVRInput.Get(OVRInput.RawButton.RIndexTrigger))
|
||||
if (!photonView.IsMine) return; // If it's not the local player's object, don't execute the input code
|
||||
|
||||
HandleInput();
|
||||
HandleRotation();
|
||||
}
|
||||
|
||||
void HandleInput()
|
||||
{
|
||||
// Handle color change input
|
||||
if (OVRInput.GetUp(OVRInput.RawButton.Y) || OVRInput.Get(OVRInput.RawButton.RIndexTrigger))
|
||||
{
|
||||
colorizeScript.ColorizeCountries(selectedYear);
|
||||
Debug.Log("Hello From inside the if conidition");
|
||||
//colorizeScript.map.ToggleCountrySurface("Brazil", true, Color.green);
|
||||
}*/
|
||||
photonView.RPC("ColorizeCountriesRPC", RpcTarget.All, selectedYear); // Call RPC to colorize countries for all players
|
||||
Debug.Log("Hello from inside the if condition");
|
||||
}
|
||||
|
||||
// Handle year selection logic
|
||||
if (OVRInput.GetUp(OVRInput.RawButton.A))
|
||||
{
|
||||
//selectedYear = Mathf.Max(selectedYear - 1, 1991); // Adjust year bounds as needed
|
||||
//Debug.Log("Selected Year:" + selectedYear);
|
||||
//colorizeScript.ColorizeCountries(selectedYear);
|
||||
colorizeScript.map.ToggleCountrySurface("Iran", true, Color.blue);
|
||||
|
||||
SelectPreviousYear();
|
||||
}
|
||||
else if (OVRInput.GetUp(OVRInput.RawButton.B))
|
||||
{
|
||||
//selectedYear = Mathf.Min(selectedYear + 1, 2021); // Adjust year bounds as needed
|
||||
//Debug.Log("Selected Year:" + selectedYear);
|
||||
//colorizeScript.ColorizeCountries(selectedYear);
|
||||
colorizeScript.map.ToggleCountrySurface("Iran", true, Color.red);
|
||||
SelectNextYear();
|
||||
}
|
||||
//End test
|
||||
//// Check if there is a connected gamepad
|
||||
//if (Gamepad.current != null)
|
||||
//{
|
||||
// Vector2 rotationInput = Gamepad.current.rightStick.ReadValue();
|
||||
// // Vector2 rotationInput = new Vector2(Input.GetAxis("RightStickHorizontal"), Input.GetAxis("RightStickVertical"));
|
||||
//
|
||||
//
|
||||
// // Rotate around the Y axis
|
||||
// transform.Rotate(0, rotationInput.x * rotateSpeed * Time.deltaTime, 0);
|
||||
//}
|
||||
}
|
||||
|
||||
|
||||
// Documentation from: https://developer.oculus.com/documentation/unity/unity-tutorial-basic-controller-input/
|
||||
|
||||
|
||||
/*
|
||||
//if (OVRInput.Get(OVRInput.RawButton.RIndexTrigger))
|
||||
if (OVRInput.GetUp(OVRInput.RawButton.A))
|
||||
{
|
||||
//// Testing send data to Data UI Manager
|
||||
//DataFormatWorld data = new DataFormatWorld();
|
||||
//data.countryName = "Sweden";
|
||||
//data.co2emissions = 2300;
|
||||
|
||||
// Read a value from the CSV file
|
||||
DataFormatWorld data = dataManager.GetTestValueFromYear();
|
||||
dataManager.SetDataToUI(data);
|
||||
}*/
|
||||
|
||||
|
||||
|
||||
|
||||
/// Rotate with the thumbsticks
|
||||
|
||||
// Calculate a proportion in the rotation (degrees per second)
|
||||
void HandleRotation()
|
||||
{
|
||||
step = rotateSpeed * Time.deltaTime;
|
||||
|
||||
if (OVRInput.Get(OVRInput.RawButton.RThumbstickLeft))
|
||||
{
|
||||
globe.transform.Rotate(0, step, 0);
|
||||
Debug.Log("Right Thumbstick detected - Left");
|
||||
RotateLeft();
|
||||
}
|
||||
|
||||
if (OVRInput.Get(OVRInput.RawButton.RThumbstickRight))
|
||||
{
|
||||
globe.transform.Rotate(0, -step, 0);
|
||||
Debug.Log("Right Thumbstick detected - Right");
|
||||
RotateRight();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void SelectPreviousYear()
|
||||
{
|
||||
selectedYear = Mathf.Max(selectedYear - 1, 1991); // Adjust year bounds as needed
|
||||
photonView.RPC("UpdateSelectedYearRPC", RpcTarget.All, selectedYear); // Call RPC to update selected year for all players
|
||||
}
|
||||
|
||||
void SelectNextYear()
|
||||
{
|
||||
selectedYear = Mathf.Min(selectedYear + 1, 2018); // Adjust year bounds as needed
|
||||
photonView.RPC("UpdateSelectedYearRPC", RpcTarget.All, selectedYear); // Call RPC to update selected year for all players
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void UpdateSelectedYearRPC(int year)
|
||||
{
|
||||
selectedYear = year;
|
||||
Debug.Log("Selected Year: " + selectedYear);
|
||||
colorizeScript.ColorizeCountries(selectedYear);
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void ColorizeCountriesRPC(int year)
|
||||
{
|
||||
Debug.Log("Colorizing countries for year: " + year);
|
||||
colorizeScript.ColorizeCountries(year);
|
||||
}
|
||||
|
||||
void RotateLeft()
|
||||
{
|
||||
transform.Rotate(0, step, 0);
|
||||
photonView.RPC("RotateLeftRPC", RpcTarget.Others); // Send RPC to other clients
|
||||
Debug.Log("Right Thumbstick detected - Left");
|
||||
}
|
||||
|
||||
void RotateRight()
|
||||
{
|
||||
transform.Rotate(0, -step, 0);
|
||||
photonView.RPC("RotateRightRPC", RpcTarget.Others); // Send RPC to other clients
|
||||
Debug.Log("Right Thumbstick detected - Right");
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void RotateLeftRPC()
|
||||
{
|
||||
transform.Rotate(0, step, 0);
|
||||
}
|
||||
|
||||
[PunRPC]
|
||||
void RotateRightRPC()
|
||||
{
|
||||
transform.Rotate(0, -step, 0);
|
||||
}
|
||||
}
|
@ -79,6 +79,6 @@ Material:
|
||||
- _UVSec: 0
|
||||
- _ZWrite: 1
|
||||
m_Colors:
|
||||
- _Color: {r: 0.25576973, g: 1, b: 0, a: 1}
|
||||
- _Color: {r: 0, g: 0.20537019, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
File diff suppressed because one or more lines are too long
@ -49,6 +49,12 @@ MonoBehaviour:
|
||||
- SendSessionStart
|
||||
- CheckForLocalAnchors
|
||||
- OnColocatedAck
|
||||
- ColorizeCountriesRPC
|
||||
- RotateLeft
|
||||
- RotateLeftRPC
|
||||
- RotateRight
|
||||
- RotateRightRPC
|
||||
- UpdateSelectedYearRPC
|
||||
DisableAutoOpenWizard: 1
|
||||
ShowSettings: 1
|
||||
DevRegionSetOnce: 1
|
||||
|
@ -534,7 +534,7 @@ PlayerSettings:
|
||||
iPhone: 0
|
||||
tvOS: 0
|
||||
overrideDefaultApplicationIdentifier: 1
|
||||
AndroidBundleVersionCode: 35
|
||||
AndroidBundleVersionCode: 38
|
||||
AndroidMinSdkVersion: 32
|
||||
AndroidTargetSdkVersion: 0
|
||||
AndroidPreferredInstallLocation: 0
|
||||
@ -777,7 +777,7 @@ PlayerSettings:
|
||||
- m_BuildTarget: iOSSupport
|
||||
m_GraphicsJobs: 0
|
||||
- m_BuildTarget: WindowsStandaloneSupport
|
||||
m_GraphicsJobs: 1
|
||||
m_GraphicsJobs: 0
|
||||
- m_BuildTarget: XboxOnePlayer
|
||||
m_GraphicsJobs: 1
|
||||
- m_BuildTarget: LuminSupport
|
||||
|
Loading…
x
Reference in New Issue
Block a user