/// <summary> /// This function adds a component of type OriginObject to obj containing information about the object from which it is derived. /// This info is used for replicating this object while loading from a save file. /// </summary> /// <param name="obj"></param> /// <param name="originName"></param> /// <param name="childOfMultiMesh"></param> private void AddOrigin(GameObject obj, string originName, bool childOfMultiMesh) { OriginObject OriObj = obj.AddComponent <OriginObject>(); OriObj.originObjectName = originName; OriObj.originObjectHasMultipleMeshes = childOfMultiMesh; OriObj.meshName = obj.GetMesh().name; }
/// <summary> /// Origin Data Constructor /// </summary> /// <param name="obj">UnityEngine.GameObject</param> public OriginData(GameObject obj) { if (obj.GetComponent <OriginObject>() != null) // uses the origin data in the object { OriginObject oriData = obj.GetComponent <OriginObject>(); originObjectName = oriData.originObjectName; originObjectHasMultipleMeshes = oriData.originObjectHasMultipleMeshes; meshName = oriData.meshName; } else // tries to create an origin { originObjectName = null; originObjectHasMultipleMeshes = false; if (obj.GetComponent <MeshFilter>() != null) // for the directional light { meshName = obj.GetComponent <MeshFilter>().name; } else // this case only happens if it is not meant to be saved or loaded { meshName = null; } } }