public void LoadRepObject() { if (replicatedObject == null) { if (IS_NOT_NULL(replicatedObjectPrefab)) { replicatedObject = Instantiate(replicatedObjectPrefab); } } string serializedBAnchorInformation = PlayerPrefs.GetString("TEST_Anchor", "Not_Init"); if (serializedBAnchorInformation == "Not_Init") { LogConsoleError("Trying to load a BAnchor that was never saved"); return; } //BAnchorInformation bAnchorInformation = JsonConvert.DeserializeObject<BAnchorInformation>(serializedBAnchorInformation); BAnchorInformation bAnchorInformation = BUtils.DeserializeObject <BAnchorInformation>(serializedBAnchorInformation); if (IS_NOT_NULL(bAnchorInformation)) { replicatedObject.SetTransformedPosition(bAnchorInformation.TransformedPosition); replicatedObject.SetTransformedRotation(bAnchorInformation.TransformedRotation); } }
public void SetRepObject() { if (IS_NOT_NULL(ARManager.Instance)) { // Spawn or replace if (replicatedObject == null) { if (IS_NOT_NULL(replicatedObjectPrefab)) { replicatedObject = Instantiate(replicatedObjectPrefab, ARCursor.Instance.GetCursorPosition(), ARCursor.Instance.GetCursorRotation()); } } else { replicatedObject.transform.position = ARCursor.Instance.GetCursorPosition(); replicatedObject.transform.rotation = ARCursor.Instance.GetCursorRotation(); } BAnchorInformation anchorInformation = replicatedObject.GetBAnchorInformation(); string serializedBAnchorInformation = BUtils.SerializeObject(anchorInformation); // Save position and rotation PlayerPrefs.SetString("TEST_Anchor", serializedBAnchorInformation); } }
private void On_AR_BAnchorSpawned(BEHandle <BAnchorInformation, string> handle) { BAnchorInformation bAnchorInformation = handle.Arg1; string bAnchorID = handle.Arg2; BAnchor bAnchorPrefab = GetBAnchorPrefab(bAnchorID); if (handle.InvokingNetworkID != BEventManager.Instance.LocalNetworkID && IS_NOT_NULL(bAnchorPrefab) && IS_NOT_NULL(bAnchorInformation)) { BAnchor spawnedBAnchor = Instantiate(bAnchorPrefab, Vector3.zero, Quaternion.identity); spawnedBAnchor.SetTransformedPosition(bAnchorInformation.TransformedPosition); spawnedBAnchor.SetTransformedRotation(bAnchorInformation.TransformedRotation); spawnedBAnchor.Owner = handle.InvokingNetworkID; BEventsCollection.AR_BAnchorSpawned.Invoke(new BEHandle <BAnchorInformation, string>(bAnchorInformation, bAnchorID), BEventReplicationType.LOCAL, true); } }
private void On_DZ_DroneBallSpawned(BEHandle <BAnchorInformation> handle) { if (BEventManager.Instance.LocalNetworkID != handle.InvokingNetworkID && IS_NOT_NULL(ballDronePrefab)) { // Destroy exsiting Ball Drone BallDroneBAnchor existingBallDrone = FindObjectOfType <BallDroneBAnchor>(); if (existingBallDrone) { Destroy(existingBallDrone.gameObject); } // Spawn new BAnchorInformation bAnchorInformation = handle.Arg1; BallDroneBAnchor ballDrone = Instantiate(ballDronePrefab); ballDrone.Owner = handle.InvokingNetworkID; ballDrone.SetTransformedPosition(bAnchorInformation.TransformedPosition); ballDrone.SetTransformedRotation(bAnchorInformation.TransformedRotation); } }
private void On_AR_BAnchorReplicateTransform(BEHandle <BAnchorInformation, string> handle) { ENetworkID callingNetworkID = handle.InvokingNetworkID; if (bAnchorID == handle.Arg2 && callingNetworkID == bAnchor.Owner && ARE_NOT_EQUAL(callingNetworkID, BEventManager.Instance.LocalNetworkID) && IS_NOT_NULL(bAnchor)) { BAnchorInformation bAnchorInformation = handle.Arg1; if (interpolateReplication == false) { bAnchor.SetTransformedPosition(bAnchorInformation.TransformedPosition); bAnchor.SetTransformedRotation(bAnchorInformation.TransformedRotation); } else { inverseRepTransformedPosition = ARManager.Instance.GetInverseTransformedPosition(bAnchorInformation.TransformedPosition); inverseRepTransformedRotation = ARManager.Instance.GetInverseTransformedRotation(bAnchorInformation.TransformedRotation); } } }
private void ReplicateTransform() { BAnchorInformation bAnchorInformation = bAnchor.GetBAnchorInformation(); BEventsCollection.AR_BAnchorReplicateTransform.Invoke(new BEHandle <BAnchorInformation, string>(bAnchorInformation, bAnchorID), BEventReplicationType.TO_ALL_OTHERS, false); }