public void AddOneFurniture() { Array arr = Enum.GetValues(typeof(FurnitureType)); int idx = UnityEngine.Random.Range(1, arr.Length); FurnitureType type = (FurnitureType)arr.GetValue(idx); Furniture f = FurnitureUtil.LoadFurnitureByType(type, furnituresParent); f.InitData(FurnitureUtil.FurnitureType2Config(type), new FurnitureSaveData()); }
private void SaveSetFurnitures() { Furniture[] fs = furnituresParent.GetComponentsInChildren <Furniture>(); List <FurnitureSaveData> sds = new List <FurnitureSaveData>(); foreach (Furniture f in fs) { if (f.m_InitData.isSeted) { f.RefreshSaveDataPos(); sds.Add(f.m_SaveData); } } FurnitureUtil.SaveFurnitureData(floor, sds); }
/// <summary> /// 加载放好的家具 /// </summary> private void LoadSetFurnitures() { List <FurnitureSaveData> datas = FurnitureUtil.LoadFurnitureData(floor); if (datas == null || datas.Count <= 0) { return; } foreach (FurnitureSaveData sd in datas) { Furniture f = FurnitureUtil.LoadFurnitureByType(sd.type, furnituresParent); f.InitData(FurnitureUtil.FurnitureType2Config(sd.type), sd); } }