public override void InitUI()
    {
        base.InitUI();
        _maleToggle = transform.Find("toggle/Toggle_male").gameObject.GetComponent <MyToggle>();
        _maleToggle.onValueChanged.AddListener((toogle) =>
        {
            if (!toogle.isOn)
            {
                SetRandomName(_xingArr, false);
            }
        });
        _femaleToggle = transform.Find("toggle/Toggle_female").gameObject.GetComponent <MyToggle>();
        _femaleToggle.onValueChanged.AddListener((toogle) =>
        {
            if (!toogle.isOn)
            {
                SetRandomName(_xingArr, true);
            }
        });

        CurrentSelectedObj = transform.Find("toggle/Toggle_male").gameObject;

        _toggleGroup = transform.Find("toggle").GetComponent <MyToggleGroup>();
        _name        = transform.Find("nickname/Text_nickname").GetComponent <Text>();

        GameObject dice = transform.Find("nickname/Image_dice").gameObject;

        _diceBtn = dice.GetComponent <MyButton>();
        _diceBtn.onClick.AddListener(OnDiceClick);
        GameObject randomNameTipsObj = transform.Find("nickname/Image_tips").gameObject;

        dice.GetComponent <MyButton>().OnSelectedShowObj = randomNameTipsObj;

        transform.Find("Button_enterGame").GetComponent <MyButton>().onClick.AddListener(OnEnterGameClick);
    }
Exemple #2
0
 public void RegisterToggle(MyToggle toggle)
 {
     if (!m_Toggles.Contains(toggle))
     {
         m_Toggles.Add(toggle);
     }
 }
Exemple #3
0
 public void UnregisterToggle(MyToggle toggle)
 {
     if (m_Toggles.Contains(toggle))
     {
         m_Toggles.Remove(toggle);
     }
 }
Exemple #4
0
 private void ValidateToggleIsInGroup(MyToggle toggle)
 {
     if (toggle == null || !m_Toggles.Contains(toggle))
     {
         throw new ArgumentException(string.Format("MyToggle {0} is not part of ToggleGroup {1}", new object[] { toggle, this }));
     }
 }
 public override bool OnOptionsItemSelected(IMenuItem item)
 {
     if (MyToggle.OnOptionsItemSelected(item))
     {
         return(true);
     }
     return(base.OnOptionsItemSelected(item));
 }
Exemple #6
0
    public void NotifyToggleOn(MyToggle toggle)
    {
        ValidateToggleIsInGroup(toggle);

        // disable all toggles in the group

        if (!m_optional)
        {
            return;
        }

        for (var i = 0; i < m_Toggles.Count; i++)
        {
            if (m_Toggles[i] == toggle)
            {
                continue;
            }

            m_Toggles[i].isOn = false;
        }
    }
Exemple #7
0
    public static Dictionary <string, MyToggle> ReadMyToggle()
    {
        string dllPath =
            System.IO.Path.Combine(System.IO.Directory.GetCurrentDirectory(),
                                   "Library/ScriptAssemblies/Assembly-CSharp.dll");

        IList <string> list = new List <string>(dataSeetMyToggleDictionary.Keys);

        foreach (string str in list)
        {
            dataSeetMyToggleDictionary[str].Validate = false;
        }

        Assembly asm = Assembly.LoadFile(dllPath);

        Type[] types = asm.GetTypes();
        foreach (Type t in types)
        {
            if (t.Namespace == "MakeDataNamespace")
            {
                if (t.Name != "DataMakeSheet")
                {
                    if (dataSeetMyToggleDictionary.ContainsKey(t.Name))
                    {
                        dataSeetMyToggleDictionary[t.Name].Validate = true;
                    }
                    else
                    {
                        MyToggle toggle = new MyToggle();
                        toggle.Enable   = true;
                        toggle.Validate = true;
                        toggle.srcType  = t;
                        dataSeetMyToggleDictionary.Add(t.Name, toggle);
                    }
                }
            }
        }
        return(dataSeetMyToggleDictionary);
    }