void UpdateData(bool grabbed, int grabOwner, Vector3 position, Quaternion rotation, Vector3 velocity, Vector3 angularVelocity, int parentId, string parentPath) { // Parenting var actualNref = NetworkReference.FromTransform(transform.parent); var newNref = NetworkReference.FromIdAndPath(parentId, parentPath); Debug.Log("Parenting: " + actualNref + " NewRef: " + newNref + " Grabbed: " + grabbed); if (actualNref != newNref) { //Debug.Log("Reparenting from " + actualNref + " to " + newNref); GameObject newParent = newNref.FindObject(); //Debug.Log("New parent " + newParent); transform.parent = newParent != null ? newParent.transform : null; } interactableObject.isKinematic = grabbed; SetState(grabOwner); if (rigidBody != null) { rigidBody.velocity = velocity; rigidBody.angularVelocity = angularVelocity; } transform.position = position; transform.rotation = rotation; }
protected override void RecvState(Hashtable content) { int parentId = (int)content["pid"]; string path = (string)content["pth"]; NetworkReference nref = NetworkReference.FromIdAndPath(parentId, path); InitState(nref); ApplyState(); }
private void SetPanoramaFromObject(int refId, string refPath) { GameObject obj = NetworkReference.FromIdAndPath(refId, refPath).FindObject(); if (obj != null) { Renderer objectRenderer = obj.GetComponent <Renderer>(); if (objectRenderer != null) { projSphereRenderer.material.SetTexture("_MainTex", objectRenderer.material.GetTexture("_MainTex")); projSphereRenderer.material.SetColor("_Color", Color.white); } } }