/// <summary> /// Receives the character data from loading a file then parses that data /// </summary> /// <param name="data">Data.</param> public void ReceiveData(ICharacterSaveData_Act1 data) { // Send that data back to the character // _name = data.Name; // Receive Scene Data _scene = data.Scene; // Receive Cam Data _lastCamSinceActive = data.LastCamSinceActive; // Receive serializable transform data _transformData = data.TransformData; // After getting the transform data, set the actual transform transform.position = new Vector3 (_transformData.Position.X, _transformData.Position.Y, _transformData.Position.Z); transform.localScale = new Vector3 (_transformData.LocalScale.X, _transformData.LocalScale.Y, _transformData.LocalScale.Z); transform.rotation = new Quaternion (_transformData.Rotation.X, _transformData.Rotation.Y, _transformData.Rotation.Z, _transformData.Rotation.W); // Retreive Inventory Data from the character data // Search through all inventory data and add it to the inventory foreach (IItem item in data.Items) { Inventory.AddItemToNextEmpty(item); } // Receive Room Data from the data }
public SavedObject(Character characterInfo, Transform transform, string prefabName) { this.characterInfo = characterInfo; this.transform = transform; this.prefabName = prefabName; }
public SavedObject() { characterInfo = new SerializableCharacter(); transform = new SerializableTransform(); prefabName = ""; }
public void SendBeginInterraction(NVRInteractable item, NVRHand hand) { SerializableTransform t = new SerializableTransform(item.transform.position - hand.transform.position, item.transform.rotation); photonView.RPC("ReceiveBeginInteraction", PhotonTargets.Others, SerializationToolkit.ObjectToByteArray(t), hand.IsRight, GetObjectID(item), NetworkPlayerManager.Instance.playerID); }
public Item() { Type = ItemType.Unknown; Transform = new SerializableTransform(); Color = new float[] { 0, 0, 0, 0 }; }
Serializable Serialize(GameObject sObject) { Serializable output = new Serializable(); CustomScript cs = sObject.GetComponent <CustomScript>(); for (int j = 0; j < cs.componentList.Length; j++) { /*Adds the Transform object for serialization*/ if (cs.componentList[j].GetType().Name.Contains("Transform")) { Debug.Log("Added Transform"); SerializableTransform sTransform = new SerializableTransform(); sTransform.name = "Transform"; sTransform.position = cs.gameObject.transform.position; sTransform.rotation = cs.gameObject.transform.eulerAngles; sTransform.scale = cs.gameObject.transform.localScale; output.components.Add(sTransform); } else if (cs.componentList[j].GetType().Name.Contains("Renderable")) { SerializableMesh sRenderable = new SerializableMesh(); sRenderable.name = "Renderable"; Renderable r = cs.gameObject.GetComponent <Renderable>(); if (sRenderable != null) { sRenderable.mesh = r.data.mesh; sRenderable.material = r.data.material; sRenderable.albedo = r.data.albedo; sRenderable.metal = r.data.metal; sRenderable.roughness = r.data.roughness; sRenderable.normal = r.data.normal; sRenderable.height = r.data.height; sRenderable.ao = r.data.ao; sRenderable.emissive = r.data.emissive; } output.components.Add(sRenderable); } else if (cs.componentList[j].GetType().Name.Contains("MeshFilter")) /*Adds the MeshFilter object for serialization*/ { Debug.Log("MeshRenderer Serialization is deprecated. It will probably be removed in a future update"); //Debug.Log("Added MeshFilter"); //SerializableMesh sMesh = new SerializableMesh(); //sMesh.name = "MeshFilter"; //MeshFilter mf = cs.gameObject.GetComponent<MeshFilter>(); //MeshRenderer mr = cs.gameObject.GetComponent < MeshRenderer>(); //sMesh.mesh = mf.sharedMesh.name; //sMesh.material = mr.sharedMaterial.name; //sMesh.castShadows = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On; //output.components.Add(sMesh); } else if (cs.componentList[j].GetType().Name.Contains("MeshRenderer")) /*Adds the MeshRenderer object for serialization*/ { Debug.Log("MeshRenderer Serialization is deprecated. It will probably be removed in a future update"); // Debug.Log("Added MeshRenderer"); // SerializableMeshRenderer sMeshRenderer = new SerializableMeshRenderer(); // sMeshRenderer.name = "MeshRenderer"; // MeshRenderer mr = cs.gameObject.GetComponent<MeshRenderer>(); // sMeshRenderer.material = mr.sharedMaterial.name; // sMeshRenderer.castShadows = mr.shadowCastingMode == UnityEngine.Rendering.ShadowCastingMode.On; // output.components.Add(sMeshRenderer); } else if (cs.componentList[j].GetType().Name.Contains("Rigidbody")) /*Adds the Rigidbody object for serialization */ { Debug.Log("Added Rigidbody"); SerializableRigidbody sRigidbody = new SerializableRigidbody(); sRigidbody.name = "Rigidbody"; Rigidbody rb = cs.gameObject.GetComponent <Rigidbody>(); sRigidbody.mass = rb.mass; sRigidbody.drag = rb.drag; sRigidbody.angularDrag = rb.angularDrag; sRigidbody.useGravity = rb.useGravity; sRigidbody.isKinematic = rb.isKinematic; sRigidbody.freezeXPos = rb.constraints == RigidbodyConstraints.FreezePositionX; sRigidbody.freezeYPos = rb.constraints == RigidbodyConstraints.FreezePositionY; sRigidbody.freezeZPos = rb.constraints == RigidbodyConstraints.FreezePositionZ; sRigidbody.freezeXRot = rb.constraints == RigidbodyConstraints.FreezeRotationX; sRigidbody.freezeYRot = rb.constraints == RigidbodyConstraints.FreezeRotationY; sRigidbody.freezeZRot = rb.constraints == RigidbodyConstraints.FreezeRotationZ; output.components.Add(sRigidbody); } else if (cs.componentList[j].GetType().Name.Contains("Collider")) /*Adds the Collider object for serialization*/ { Debug.Log("Added Collider"); if (cs.gameObject.GetComponent <BoxCollider>()) { SerializableBoxCollider sBCollider = new SerializableBoxCollider(); sBCollider.name = "BoxCollider"; BoxCollider bc = cs.gameObject.GetComponent <BoxCollider>(); sBCollider.isTrigger = bc.isTrigger; sBCollider.center = bc.center; sBCollider.size = bc.size; output.components.Add(sBCollider); } else if (cs.gameObject.GetComponent <SphereCollider>()) { SerializableSphereCollider sSCollider = new SerializableSphereCollider(); sSCollider.name = "SphereCollider"; SphereCollider sc = cs.gameObject.GetComponent <SphereCollider>(); sSCollider.isTrigger = sc.isTrigger; sSCollider.center = sc.center; sSCollider.radius = sc.radius; output.components.Add(sSCollider); } } else { SerializableComponent Script = new SerializableComponent(); string fName = cs.componentList[j].GetType().ToString(); if (cs.componentList[j].GetType().ToString().Contains("UnityEngine.")) { Debug.Log(fName.Length); Script.name = fName.Substring(12); } else { Script.name = fName; } output.components.Add(Script); } } return(output); }