//===================================================== public void Refresh() { CheckReferences(); // Update chest-model //Debug.Log( "Model type: " + _type + " : " + _model ); var mdlChest = ResourcesChests.GetModel(_type, _model); var chestModel = Instantiate(mdlChest) as GameObject; Init(chestModel); // Special Case: editor changes only update _rewardSwitchItem because of enumerated type so forcing update on _reward // Do we need to set the chest-reward? if (_reward == null) { // Set reward (gems or a card). Special 'key' items only set in inspector for large chests (NULL forces normal reward setup) _rewardSwitchItem = eSwitchItem.NULL; SetRewardItem(_rewardSwitchItem, _cardClassification, _cardRarity, _cardCondition); } else { if (_reward.SwitchItem != _rewardSwitchItem) { SetRewardItem(_rewardSwitchItem, _cardClassification, _cardRarity, _cardCondition); } } }
//===================================================== private static void AddChestOfType(eChestType type) { var pfb = ResourcesChests.GetPrefab(); var mdl = ResourcesChests.GetModel(type, 0); if (pfb == null) { return; } // Create containers for chests if they don't already exist var container = GameObject.Find("Chests"); var small = GameObject.Find("Small"); var medium = GameObject.Find("Mediun"); var large = GameObject.Find("Large"); if (container == null) { container = CreateContainer("Chests"); if (small == null) { small = CreateContainer("Small", container); } if (medium == null) { medium = CreateContainer("Mediun", container); } if (large == null) { large = CreateContainer("Large", container); } } var prefab = PrefabUtility.InstantiatePrefab(pfb) as GameObject; if (prefab == null) { return; } var script = prefab.GetComponent <Chest>(); switch (type) { case eChestType.SMALL: prefab.name = "SmallChest"; prefab.transform.parent = small.transform; break; case eChestType.MEDIUM: prefab.name = "MediumChest"; prefab.transform.parent = medium.transform; break; case eChestType.LARGE: prefab.name = "LargeChest"; prefab.transform.parent = large.transform; break; } if (script != null) { script.Type = type; if (mdl != null) { var model = PrefabUtility.InstantiatePrefab(mdl) as GameObject; script.Init(model); } } PositionObjectAndSelect(prefab); }