예제 #1
0
        protected override void GenerateButtons()
        {
            //Get List of ButtonTypes that should be created on Dialog
            List <ButtonTypeEnum> buttonTypes = new List <ButtonTypeEnum>();

            foreach (ButtonTypeEnum buttonType in Enum.GetValues(typeof(ButtonTypeEnum)))
            {
                if (buttonType == ButtonTypeEnum.None)
                {
                    continue;
                }

                // If this button type flag is set
                if ((buttonType & result.Buttons) == buttonType)
                {
                    buttonTypes.Add(buttonType);
                }
            }

            oneButtonSet = new GameObject[1];
            twoButtonSet = new GameObject[2];

            //Activate/Deactivate buttons and set Titles
            foreach (Transform child in transform)
            {
                if (child.name == "ButtonParent")
                {
                    for (int childIndex = 0; childIndex < child.transform.childCount; ++childIndex)
                    {
                        Transform t = child.transform.GetChild(childIndex);
                        if (t != null)
                        {
                            DialogButton button = t.GetComponent <DialogButton>();
                            if (button != null)
                            {
                                button.ParentDialog = this;

                                if (button.name.Contains("ButtonOne"))
                                {
                                    button.gameObject.SetActive(buttonTypes.Count == 1);

                                    if (buttonTypes.Count == 1)
                                    {
                                        oneButtonSet[0] = button.gameObject;
                                        button.SetTitle(buttonTypes[0].ToString());
                                        button.ButtonTypeEnum = buttonTypes[0];
                                    }
                                }
                                else if (button.name.Contains("ButtonTwo"))
                                {
                                    button.gameObject.SetActive(buttonTypes.Count > 1);

                                    if (buttonTypes.Count > 1)
                                    {
                                        if (button.name.Contains("A"))
                                        {
                                            twoButtonSet[0] = button.gameObject;
                                            button.SetTitle(buttonTypes[0].ToString());
                                            button.ButtonTypeEnum = buttonTypes[0];
                                        }
                                        else if (button.name.Contains("B"))
                                        {
                                            twoButtonSet[1] = button.gameObject;
                                            button.SetTitle(buttonTypes[1].ToString());
                                            button.ButtonTypeEnum = buttonTypes[1];
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }