コード例 #1
0
    private void DropdownValueChangedHandler(Dropdown target)
    {
        if (target.value == 0)
        {
            {
                isAssigned = false; isAssigned = false;

                //Remove advisor from current planet
                if (advisor.workingPlanet != null)
                {
                    advisor.workingPlanet.RemoveAdvisor(advisor);
                    advisor.workingPlanet = null;
                }
            }
        }
        else
        {
            {
                isAssigned = true; isAssigned = true;


                //Assign advisor to planet here	            //Remove advisor from current planet
                if (advisor.workingPlanet != null)
                {
                    advisor.workingPlanet.RemoveAdvisor(advisor);
                    advisor.workingPlanet = null;
                }

                //Assign advisor to new planet
                Planet p = PlanetController.instance.planets.Find(t => t.planetName == target.options[target.value].text);
                p.AddAdvisor(advisor);
                advisor.workingPlanet = p;
            }
        }
        Debug.Log("selected: " + target.options[target.value].text);
    }