public IEnumerator Load(World.Data world) { ActionProgressBar.UpdateProgress("Loading Map Prefabs", 0f); yield return(null); yield return(null); Stopwatch sw = Stopwatch.StartNew(); for (int i = 0; i < world.prefabData.Count; i++) { if (sw.Elapsed.TotalSeconds > 1f || i == 0 || i == world.prefabData.Count - 1) { ActionProgressBar.UpdateProgress("Loading Map Prefabs", (float)world.prefabData.Count / (float)i); yield return(null); yield return(null); sw.Reset(); } ProtoBuf.PrefabData prefabData = world.prefabData[i]; CreatePrefab(StringPool.Get(prefabData.id), prefabData.category, prefabData.position, prefabData.rotation, prefabData.scale); } sw.Stop(); }
internal ProtoBuf.PrefabData GetPrefabData() { ProtoBuf.PrefabData data = new ProtoBuf.PrefabData(); data.id = StringPool.Get(gameObject.name); data.category = string.IsNullOrEmpty(category) ? "Decor" : category; Vector3 position = gameObject.transform.position; Vector3 rotation = gameObject.transform.rotation.eulerAngles; Vector3 scale = gameObject.transform.localScale; data.position = new ProtoBuf.VectorData() { x = position.x, y = position.y, z = position.z }; data.rotation = new ProtoBuf.VectorData() { x = rotation.x, y = rotation.y, z = rotation.z }; data.scale = new ProtoBuf.VectorData() { x = scale.x, y = scale.y, z = scale.z }; return(data); }