Script WiP PUN2
Interactions with PUN not yet finished.
This commit is contained in:
parent
09fb3fadc4
commit
fd53aa04bb
Assets
Oculus
OurScripts
SharedSpatialAnchors
Prefabs/Resources
Scenes
Scripts
WorldPoliticalMapGlobeEdition
Demos/01 GeneralDemo
Resources/Materials
Scripts/Core/Internal
ProjectSettings
@ -15,10 +15,10 @@ MonoBehaviour:
|
||||
targetDeviceTypes: 030000000200000004000000
|
||||
allowOptional3DofHeadTracking: 0
|
||||
handTrackingSupport: 0
|
||||
handTrackingFrequency: 0
|
||||
handTrackingFrequency: 1
|
||||
handTrackingVersion: 0
|
||||
anchorSupport: 1
|
||||
sharedAnchorSupport: 2
|
||||
sharedAnchorSupport: 1
|
||||
renderModelSupport: 0
|
||||
trackedKeyboardSupport: 0
|
||||
bodyTrackingSupport: 0
|
||||
|
@ -14,7 +14,7 @@ public class ColorizeCountriesScript : MonoBehaviour
|
||||
|
||||
void Start()
|
||||
{
|
||||
map = WorldMapGlobe.instance;
|
||||
//map = WorldMapGlobe.instance;
|
||||
|
||||
//map.ToggleCountrySurface("Brazil", true, Color.green);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
using UnityEngine;
|
||||
using Photon.Pun;
|
||||
using Photon.Realtime;
|
||||
using WPM;
|
||||
using PhotonPun = Photon.Pun;
|
||||
using PhotonRealtime = Photon.Realtime;
|
||||
|
||||
public class GlobeInteraction : MonoBehaviourPunCallbacks
|
||||
public class GlobeInteraction : MonoBehaviour //PunCallbacks
|
||||
{
|
||||
private bool isInteracting = false;
|
||||
public float rotateSpeed = 100f;
|
||||
@ -11,12 +11,32 @@ public class GlobeInteraction : MonoBehaviourPunCallbacks
|
||||
private int selectedYear;
|
||||
public ColorizeCountriesScript colorizeScript;
|
||||
public DataManager dataManager;
|
||||
public GameObject globe;
|
||||
|
||||
public GameObject globePrefab;
|
||||
//public WorldMapGlobe map;
|
||||
|
||||
void Start()
|
||||
{
|
||||
selectedYear = 2018;
|
||||
|
||||
Debug.Log("BEFOREPassed spawnglobe method");
|
||||
SpawnGlobe();
|
||||
Debug.Log("Passed spawnglobe method");
|
||||
|
||||
//map = WorldMapGlobe.instance;
|
||||
|
||||
// TEST
|
||||
//PhotonNetwork.Instantiate("GlobePrefab", Vector3.zero, Quaternion.identity);
|
||||
|
||||
}
|
||||
|
||||
private void SpawnGlobe()
|
||||
{
|
||||
Debug.Log("Went to method");
|
||||
var networkedGlobe = PhotonPun.PhotonNetwork.Instantiate(globePrefab.name, new Vector3(0, 0, 0), Quaternion.identity);
|
||||
var photonGrabbable = networkedGlobe.GetComponent<PhotonGrabbableObject>();
|
||||
photonGrabbable.TransferOwnershipToLocalPlayer();
|
||||
}
|
||||
|
||||
void Update()
|
||||
@ -37,27 +57,29 @@ public class GlobeInteraction : MonoBehaviourPunCallbacks
|
||||
//{
|
||||
if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickLeft) || Input.GetKeyDown(KeyCode.N))
|
||||
{
|
||||
//photonView.RPC("RotateLeftRPC", RpcTarget.All);
|
||||
//photonView.RPC("RotateLeftRPC", RpcTarget.Others);
|
||||
RotateLeftRPC();
|
||||
//Debug.
|
||||
Debug.Log("Pressed N Left");
|
||||
|
||||
}
|
||||
|
||||
if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickRight) || Input.GetKeyDown(KeyCode.M))
|
||||
if (OVRInput.Get(OVRInput.Button.SecondaryThumbstickRight) || Input.GetKeyUp(KeyCode.M))
|
||||
{
|
||||
//photonView.RPC("RotateRightRPC", RpcTarget.All);
|
||||
//photonView.RPC("RotateRightRPC", RpcTarget.Others);
|
||||
RotateRightRPC();
|
||||
|
||||
Debug.Log("Pressed M Right");
|
||||
|
||||
}
|
||||
|
||||
if (OVRInput.Get(OVRInput.Button.One) || Input.GetKeyDown(KeyCode.K))
|
||||
{
|
||||
SelectNextYear();
|
||||
Debug.Log("Pressed Next year K");
|
||||
}
|
||||
if (OVRInput.Get(OVRInput.Button.Two) || Input.GetKeyDown(KeyCode.J))
|
||||
{
|
||||
SelectPreviousYear();
|
||||
Debug.Log("Pressed prev year J");
|
||||
}
|
||||
|
||||
/*if (!OVRInput.Get(OVRInput.Button.PrimaryThumbstickLeft) && !OVRInput.Get(OVRInput.Button.PrimaryThumbstickRight))
|
||||
@ -71,14 +93,14 @@ public class GlobeInteraction : MonoBehaviourPunCallbacks
|
||||
void RotateLeftRPC()
|
||||
{
|
||||
step = rotateSpeed * Time.deltaTime;
|
||||
transform.Rotate(0, step, 0);
|
||||
globe.transform.Rotate(0, step, 0);
|
||||
}
|
||||
|
||||
//[PunRPC]
|
||||
void RotateRightRPC()
|
||||
{
|
||||
step = rotateSpeed * Time.deltaTime;
|
||||
transform.Rotate(0, -step, 0);
|
||||
globe.transform.Rotate(0, -step, 0);
|
||||
}
|
||||
//**Rotation Code End**
|
||||
|
||||
@ -103,6 +125,7 @@ public class GlobeInteraction : MonoBehaviourPunCallbacks
|
||||
|
||||
void SelectNextYear()
|
||||
{
|
||||
|
||||
selectedYear = Mathf.Min(selectedYear + 1, 2018);
|
||||
//photonView.RPC("UpdateSelectedYearRPC", RpcTarget.All, selectedYear);
|
||||
UpdateSelectedYearRPC(selectedYear);
|
||||
|
45
Assets/OurScripts/GlobeManagerScript.cs
Normal file
45
Assets/OurScripts/GlobeManagerScript.cs
Normal file
@ -0,0 +1,45 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using WPM;
|
||||
using PhotonPun = Photon.Pun;
|
||||
using PhotonRealtime = Photon.Realtime;
|
||||
|
||||
public class GlobeManagerScript : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
public WorldMapGlobe worldMapGlobe;
|
||||
|
||||
public static GlobeManagerScript instance;
|
||||
public void Awake()
|
||||
{
|
||||
if (instance == null)
|
||||
instance = this;
|
||||
else
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
//worldMapGlobe = GetComponent<WorldMapGlobe>();
|
||||
|
||||
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void SpawnGlobe()
|
||||
{
|
||||
Debug.Log("Went to method");
|
||||
var networkedGlobe = PhotonPun.PhotonNetwork.Instantiate(worldMapGlobe.name,new Vector3(0,0,0), Quaternion.identity);
|
||||
//var photonGrabbable = networkedGlobe.GetComponent<PhotonGrabbableObject>();
|
||||
//photonGrabbable.TransferOwnershipToLocalPlayer();
|
||||
}
|
||||
}
|
11
Assets/OurScripts/GlobeManagerScript.cs.meta
Normal file
11
Assets/OurScripts/GlobeManagerScript.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7ea9a0451de098841a4345af1ab933e5
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
File diff suppressed because it is too large
Load Diff
@ -1,5 +1,5 @@
|
||||
fileFormatVersion: 2
|
||||
guid: bae2d9615fea3d44e91f0d1eb7e1d0b1
|
||||
guid: 447fa73de571f2c409e67b912500edab
|
||||
PrefabImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
File diff suppressed because one or more lines are too long
@ -33,6 +33,7 @@ public class SharedAnchorControlPanel : MonoBehaviour
|
||||
|
||||
[SerializeField]
|
||||
private GameObject cubePrefab;
|
||||
|
||||
[SerializeField]
|
||||
private GameObject roomLayoutPanelRowPrefab;
|
||||
|
||||
@ -92,6 +93,7 @@ public class SharedAnchorControlPanel : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
|
||||
transform.parent = referencePoint;
|
||||
transform.localPosition = Vector3.zero;
|
||||
transform.localRotation = Quaternion.identity;
|
||||
@ -100,6 +102,8 @@ public class SharedAnchorControlPanel : MonoBehaviour
|
||||
renderStyleText.text = "Render: " + CoLocatedPassthroughManager.Instance.visualization.ToString();
|
||||
}
|
||||
ToggleRoomButtons(false);
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void OnCreateModeButtonPressed()
|
||||
@ -175,6 +179,8 @@ public class SharedAnchorControlPanel : MonoBehaviour
|
||||
photonGrabbable.TransferOwnershipToLocalPlayer();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void ChangeUserPassthroughVisualization()
|
||||
{
|
||||
CoLocatedPassthroughManager.Instance.NextVisualization();
|
||||
|
@ -10,7 +10,7 @@ namespace WPM {
|
||||
|
||||
public GameObject rocketPrefab;
|
||||
|
||||
public WorldMapGlobe map;
|
||||
WorldMapGlobe map;
|
||||
GUIStyle labelStyle, labelStyleShadow, buttonStyle, sliderStyle, sliderThumbStyle;
|
||||
ColorPicker colorPicker;
|
||||
bool changingFrontiersColor;
|
||||
@ -27,7 +27,7 @@ namespace WPM {
|
||||
animatingField = true;
|
||||
#endif
|
||||
map.earthInvertedMode = false;
|
||||
|
||||
|
||||
// UI Setup - non-important, only for this demo
|
||||
labelStyle = new GUIStyle();
|
||||
labelStyle.alignment = TextAnchor.MiddleCenter;
|
||||
@ -84,10 +84,6 @@ namespace WPM {
|
||||
Debug.Log("Clicked on Latitude: " + latLon.x + ", Longitude: " + latLon.y);
|
||||
};
|
||||
|
||||
// Hide the GUI permanently
|
||||
avoidGUI = true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -267,10 +263,10 @@ namespace WPM {
|
||||
|
||||
|
||||
void Update() {
|
||||
//// Hide the Gui permanently
|
||||
//if (Input.GetKeyDown(KeyCode.G)) {
|
||||
// avoidGUI = !avoidGUI;
|
||||
//}
|
||||
|
||||
if (Input.GetKeyDown(KeyCode.G)) {
|
||||
avoidGUI = !avoidGUI;
|
||||
}
|
||||
|
||||
// Animates the camera field of view (just a cool effect at the begining)
|
||||
if (animatingField) {
|
||||
|
@ -2,24 +2,20 @@
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!21 &2100000
|
||||
Material:
|
||||
serializedVersion: 8
|
||||
serializedVersion: 6
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: BackFacesForZBuffer
|
||||
m_Shader: {fileID: 4800000, guid: fe944894e2fdd422783e9d2f2c239a61, type: 3}
|
||||
m_Parent: {fileID: 0}
|
||||
m_ModifiedSerializedProperties: 0
|
||||
m_ValidKeywords: []
|
||||
m_InvalidKeywords: []
|
||||
m_ShaderKeywords:
|
||||
m_LightmapFlags: 5
|
||||
m_EnableInstancingVariants: 0
|
||||
m_DoubleSidedGI: 0
|
||||
m_CustomRenderQueue: -1
|
||||
stringTagMap: {}
|
||||
disabledShaderPasses: []
|
||||
m_LockedProperties:
|
||||
m_SavedProperties:
|
||||
serializedVersion: 3
|
||||
m_TexEnvs:
|
||||
@ -59,7 +55,6 @@ Material:
|
||||
m_Texture: {fileID: 0}
|
||||
m_Scale: {x: 1, y: 1}
|
||||
m_Offset: {x: 0, y: 0}
|
||||
m_Ints: []
|
||||
m_Floats:
|
||||
- _BumpScale: 1
|
||||
- _Cutoff: 0.5
|
||||
@ -80,4 +75,3 @@ Material:
|
||||
- _Color: {r: 0, g: 0, b: 0, a: 1}
|
||||
- _ColorDummy: {r: 1, g: 1, b: 1, a: 1}
|
||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
||||
m_BuildTextureStacks: []
|
||||
|
@ -20,7 +20,6 @@ using WPM.Poly2Tri;
|
||||
using WPM.PolygonTools;
|
||||
using WPM.ClipperLib;
|
||||
using TMPro;
|
||||
using Oculus;
|
||||
|
||||
#if UNITY_EDITOR
|
||||
using UnityEditor;
|
||||
@ -781,16 +780,15 @@ namespace WPM {
|
||||
leftMouseButtonClick = simulatedMouseButtonClick == 0;
|
||||
#if VR_OCULUS
|
||||
touchPadTouchStart = false;
|
||||
if (OVRInput.GetDown(OVRInput.Button.PrimaryIndexTrigger)) {
|
||||
if (OVRinput.GetDown(OVRinput.Button.PrimaryIndexTrigger)) {
|
||||
leftMouseButtonClick = true;
|
||||
|
||||
touchPadTouchStart = touchPadTouchStays = false;
|
||||
}
|
||||
if (OVRInput.GetDown(OVRInput.Touch.PrimaryTouchpad)) {
|
||||
if (OVRinput.GetDown(OVRinput.Touch.PrimaryTouchpad)) {
|
||||
touchPadTouchStart = touchPadTouchStays = true;
|
||||
leftMouseButtonPressed = false;
|
||||
}
|
||||
if (OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick) != Misc.Vector2zero) {
|
||||
if (OVRinput.Get(OVRinput.Axis2D.PrimaryThumbstick) != Misc.Vector2zero) {
|
||||
touchPadTouchStays = true;
|
||||
hasDragged = true;
|
||||
mouseStartedDragging = true;
|
||||
@ -808,7 +806,7 @@ namespace WPM {
|
||||
leftMouseButtonPressed = leftMouseButtonClick || simulatedMouseButtonPressed == 0;
|
||||
|
||||
#if VR_OCULUS
|
||||
if (OVRInput.Get(OVRInput.Button.PrimaryIndexTrigger)) {
|
||||
if (OVRinput.Get(OVRinput.Button.PrimaryIndexTrigger)) {
|
||||
leftMouseButtonPressed = true;
|
||||
}
|
||||
#elif VR_GOOGLE
|
||||
@ -822,10 +820,10 @@ namespace WPM {
|
||||
// LEFT RELEASED
|
||||
leftMouseButtonRelease = simulatedMouseButtonRelease == 0;
|
||||
#if VR_OCULUS
|
||||
if (OVRInput.GetUp(OVRInput.Button.PrimaryIndexTrigger)) {
|
||||
if (OVRinput.GetUp(OVRinput.Button.PrimaryIndexTrigger)) {
|
||||
leftMouseButtonRelease = true;
|
||||
}
|
||||
if (OVRInput.GetUp(OVRInput.Touch.PrimaryTouchpad)) {
|
||||
if (OVRinput.GetUp(OVRinput.Touch.PrimaryTouchpad)) {
|
||||
touchPadTouchStays = false;
|
||||
}
|
||||
#elif VR_GOOGLE
|
||||
@ -844,7 +842,7 @@ namespace WPM {
|
||||
rightMouseButtonClick = input.GetMouseButtonDown(1) || simulatedMouseButtonClick == 1;
|
||||
|
||||
#if VR_OCULUS
|
||||
if (OVRInput.GetDown(OVRInput.Button.PrimaryTouchpad)) {
|
||||
if (OVRinput.GetDown(OVRinput.Button.PrimaryTouchpad)) {
|
||||
rightMouseButtonClick = true;
|
||||
touchPadTouchStays = touchPadTouchStart = false;
|
||||
}
|
||||
@ -1250,7 +1248,7 @@ namespace WPM {
|
||||
if (_dragConstantSpeed) {
|
||||
mouseDragStart = input.mousePosition;
|
||||
} else {
|
||||
mouseDragStart = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
|
||||
mouseDragStart = OVRinput.Get(OVRinput.Axis2D.PrimaryTouchpad);
|
||||
}
|
||||
|
||||
#else
|
||||
@ -1299,9 +1297,9 @@ namespace WPM {
|
||||
dragDirection.y *= -1.0f;
|
||||
dragDirection *= distFactor * _mouseDragSensitivity * Time.deltaTime * 60f;
|
||||
#elif VR_OCULUS
|
||||
dragDirection = (mouseDragStart - (Vector3)OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad));
|
||||
dragDirection = (mouseDragStart - (Vector3)OVRinput.Get(OVRinput.Axis2D.PrimaryTouchpad));
|
||||
if (dragDirection == Misc.Vector3zero) {
|
||||
dragDirection = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
|
||||
dragDirection = OVRinput.Get(OVRinput.Axis2D.PrimaryThumbstick);
|
||||
}
|
||||
if (_rotationAxisAllowed == ROTATION_AXIS_ALLOWED.X_AXIS_ONLY) {
|
||||
dragDirection.y = 0;
|
||||
@ -1431,8 +1429,8 @@ namespace WPM {
|
||||
float wheel = input.GetAxis("Mouse ScrollWheel");
|
||||
#if VR_OCULUS
|
||||
if (wheel == 0) {
|
||||
if (OVRInput.Get(OVRInput.Button.PrimaryHandTrigger)) {
|
||||
wheel = -OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick).y;
|
||||
if (OVRinput.Get(OVRinput.Button.PrimaryHandTrigger)) {
|
||||
wheel = -OVRinput.Get(OVRinput.Axis2D.PrimaryThumbstick).y;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -1487,6 +1485,7 @@ namespace WPM {
|
||||
|
||||
// Ensure camera is within min/max range
|
||||
CheckCamMinMaxDistance(cam);
|
||||
|
||||
|
||||
// Ensure camera looks straight (up or aligned with horizon depending on tilt)
|
||||
KeepCameraStraight();
|
||||
@ -1506,7 +1505,7 @@ namespace WPM {
|
||||
#if VR_GOOGLE
|
||||
mouseDragStart = GvrController.TouchPos;
|
||||
#elif VR_OCULUS
|
||||
mouseDragStart = OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad);
|
||||
mouseDragStart = OVRinput.Get(OVRinput.Axis2D.PrimaryTouchpad);
|
||||
#else
|
||||
mouseDragStart = input.mousePosition;
|
||||
UpdateCursorLocation(); // _cursorLocation has not been set yet so we call CheckMousePos before any interaction
|
||||
@ -1549,9 +1548,9 @@ namespace WPM {
|
||||
dragDirection.y *= -1.0f;
|
||||
dragDirection *= distFactor * _mouseDragSensitivity * Time.deltaTime * 60f;
|
||||
#elif VR_OCULUS
|
||||
dragDirection = (mouseDragStart - (Vector3)OVRInput.Get(OVRInput.Axis2D.PrimaryTouchpad));
|
||||
dragDirection = (mouseDragStart - (Vector3)OVRinput.Get(OVRinput.Axis2D.PrimaryTouchpad));
|
||||
if (dragDirection == Misc.Vector3zero) {
|
||||
dragDirection = OVRInput.Get(OVRInput.Axis2D.PrimaryThumbstick);
|
||||
dragDirection = OVRinput.Get(OVRinput.Axis2D.PrimaryThumbstick);
|
||||
}
|
||||
dragDirection.y *= -1.0f;
|
||||
dragDirection *= distFactor * _mouseDragSensitivity * Time.deltaTime * 60f;
|
||||
@ -1777,14 +1776,14 @@ namespace WPM {
|
||||
}
|
||||
#elif VR_OCULUS
|
||||
if (OVR_Manager != null && OVR_Manager.gameObject.activeInHierarchy) {
|
||||
Vector3 controllerPos = OVRInput.GetLocalControllerPosition(OVRInput.Controller.RTouch);
|
||||
Vector3 controllerDir = OVRInput.GetLocalControllerRotation(OVRInput.Controller.RTouch) * Vector3.forward;
|
||||
Vector3 controllerPos = OVRinput.GetLocalControllerPosition(OVRinput.Controller.RTouch);
|
||||
Vector3 controllerDir = OVRinput.GetLocalControllerRotation(OVRinput.Controller.RTouch) * Vector3.forward;
|
||||
ray = new Ray(controllerPos, controllerDir);
|
||||
} else {
|
||||
ray = new Ray(cam.transform.position, cam.transform.forward);
|
||||
}
|
||||
#else
|
||||
if (!_VREnabled) {
|
||||
if (_VREnabled) {
|
||||
ray = new Ray(cam.transform.position, cam.transform.forward);
|
||||
} else {
|
||||
Vector3 mousePos;
|
||||
|
@ -3,7 +3,8 @@
|
||||
--- !u!78 &1
|
||||
TagManager:
|
||||
serializedVersion: 2
|
||||
tags: []
|
||||
tags:
|
||||
- Globe
|
||||
layers:
|
||||
- Default
|
||||
- TransparentFX
|
||||
|
Loading…
x
Reference in New Issue
Block a user