//-------------------------------------------------------- public void SaveFrom(BasketMover bm) { duration = bm.duration; delay = bm.delay; waypoints = new Vector2[bm.waypoints.Length]; scale = bm.scale; rotation = bm.rotation; loopsCount = bm.loopsCount; loopType = bm.loopType; autoRun = bm.autoRun; System.Array.Copy(bm.waypoints, waypoints, bm.waypoints.Length); }
//-------------------------------------------------------- public void Save() { if (editingBaskets == null) { Debug.LogWarning("Data not loaded yet"); return; } Debug.LogWarning("In Design mode, only the 1st level is saved"); levelData = levels[0]; Vector3 pos = Vector3.zero; int countMoving = 0; float sumDuration = 0f; for (int i = 0; i < editingBaskets.Length; ++i) { BasketData bd = levelData.baskets[i]; Basket b = editingBaskets[i]; Transform bt = b.transform; bd.score = b.score; bd.offset = new Vector2(bt.localPosition.x, bt.localPosition.y - pos.y); bd.throwRotation = bt.localRotation.eulerAngles.z; BasketMover bm = b.GetComponent <BasketMover>(); if (bm != null) { bd.SaveFrom(bm); ++countMoving; sumDuration += bm.duration; } else { bd.SetAsStatic(); } levelData.baskets[i] = bd; pos = bt.localPosition; } levelData.averageDuration = (countMoving > 0) ? (sumDuration / countMoving) : 0f; EditorUtility.SetDirty(levelData); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); }