Exemple #1
0
        void SwitchOption(UpgradeValidator validator, int i, bool forcedValue = false)
        {
            Selection.activeGameObject = validator.gameObject;
            var currentSettings = validator.ObjectSettings.Find(x => x.Prefab == validator.CurrentObject);
            var currentIndex    = validator.ObjectSettings.IndexOf(currentSettings);

            if (!forcedValue)
            {
                currentIndex += i;
                if (currentIndex < 0)
                {
                    currentIndex = validator.ObjectSettings.Count - 1;
                }
                else if (currentIndex >= validator.ObjectSettings.Count)
                {
                    currentIndex = 0;
                }
            }
            else
            {
                if (currentIndex == i)
                {
                    return;
                }
                currentIndex = i;
            }

            GameObject go = validator.ObjectSettings[currentIndex].Prefab;

            validator.ApplyUpgrade(go, true);

            EditorUtility.SetDirty(validator.gameObject);
        }
 void UpdateSelection(int selectionID)
 {
     validator.ApplyUpgrade(validator.ObjectSettings[selectionID].Prefab);
     image.sprite = validator.CurrentObject.GetComponent <SpriteRenderer>().sprite;
 }