Esempio n. 1
0
    public static void SetButtonStateText(CompoundButton button, bool active)
    {
        CompoundButtonText text = button.GetComponent <CompoundButtonText>();

        if (text == null)
        {
            Debug.LogWarning("Missing CompoundButtonText");
            return;
        }
        TextMesh textMesh = text.TextMesh;

        if (textMesh == null)
        {
            Debug.LogWarning("Missing TextMesh");
            return;
        }
        // using material, not sharedMaterial, deliberately: we only change color of this material instance
        Color newColor = active ? ButtonActiveColor : ButtonInactiveColor;
        //Debug.Log("changing color of " + button.name + " to " + newColor.ToString());
        // both _EmissiveColor and _Color (Albedo in editor) should be set to make proper effect.
        MeshRenderer renderer = textMesh.GetComponent <MeshRenderer>();

        renderer.material.SetColor("_EmissiveColor", newColor);
        renderer.material.SetColor("_Color", newColor);
    }
        public void Initialize(AppBar newParentToolBar, AppBar.ButtonTemplate newTemplate, ButtonIconProfile newCustomProfile)
        {
            template          = newTemplate;
            customIconProfile = newCustomProfile;
            parentToolBar     = newParentToolBar;

            cButton = GetComponent <CompoundButton>();
            cButton.MainRenderer.enabled = false;
            text                  = GetComponent <CompoundButtonText>();
            text.Text             = template.Text;
            icon                  = GetComponent <CompoundButtonIcon>();
            highlightMeshRenderer = cButton.GetComponent <CompoundButtonMesh>().Renderer;

            if (customIconProfile != null)
            {
                icon.Profile  = customIconProfile;
                icon.IconName = string.Empty;
            }
            icon.IconName = template.Icon;
            initialized   = true;
            Hide();

            if (newTemplate.EventTarget != null)
            {
                // Register the button with its target interactable
                newTemplate.EventTarget.Registerinteractable(gameObject);
            }
            else
            {
                // Register the button with the parent app bar
                newParentToolBar.Registerinteractable(gameObject);
            }
        }
Esempio n. 3
0
        protected override GameObject CreateButton(SimpleMenuCollectionButton template)
        {
            GameObject newButton = base.CreateButton(template);

            // Update the button's icon and text
            // If the button doesn't have these components, ignore these settings
            CompoundButtonIcon icon = newButton.GetComponent <CompoundButtonIcon>();

            if (icon != null)
            {
                icon.IconName = template.Icon;
            }

            CompoundButtonText text = newButton.GetComponent <CompoundButtonText>();

            if (text != null)
            {
                text.Text = template.Text;
            }

            // Set the display order of the button using the transform order
            newButton.transform.SetSiblingIndex(template.Index);

            return(newButton);
        }
Esempio n. 4
0
    public void Start()
    {
        // Disable if no microphone devices are found
        if (Microphone.devices.Length == 0)
        {
            enabled = false;
            return;
        }

        if (KeywordSource == KeywordSourceEnum.None)
        {
            return;
        }

        keyWord = string.Empty;

        // Assign internal cached components
        m_button      = GetComponent <CompoundButton>();
        m_button_text = GetComponent <CompoundButtonText>();

        switch (KeywordSource)
        {
        case KeywordSourceEnum.ButtonText:
        default:
            keyWord = prevButtonText = m_button_text.Text;
            break;

        case KeywordSourceEnum.LocalOverride:
            keyWord = Keyword;
            break;
        }
    }
Esempio n. 5
0
        /// <summary>
        /// Setter Method to set the Text at the top of the Dialog.
        /// </summary>
        /// <param name="title"></param>
        public void SetTitle(string title)
        {
            CompoundButtonText compoundButtonText = GetComponent <CompoundButtonText>();

            if (compoundButtonText)
            {
                compoundButtonText.Text = title;
            }
        }
Esempio n. 6
0
        public override void setProperties(AppData.uniqueIDDevice.UIContainerData UIE)
        {
            text      = GetComponent <CompoundButtonText>();
            text.Text = UIE.displayText;

            icon          = GetComponent <CompoundButtonIcon>();
            icon.IconName = UIE.specificContainerData1;


            //finalizes in base class
            base.setProperties(UIE);
        }
Esempio n. 7
0
 /// <summary>
 /// Disables button's main collider and sets text alpha to 1/2
 /// </summary>
 /// <param name="buttonName"></param>
 /// <param name="enabled"></param>
 public void SetButtonEnabled(string buttonName, bool enabled)
 {
     for (int i = 0; i < instantiatedButtons.Length; i++)
     {
         if (instantiatedButtons[i].name.Equals(buttonName))
         {
             CompoundButton button = instantiatedButtons[i].GetComponent <CompoundButton>();
             button.ButtonState = enabled ? Button.ButtonStateEnum.Interactive : Button.ButtonStateEnum.Disabled;
             CompoundButtonText text = button.GetComponent <CompoundButtonText>();
             text.Alpha = enabled ? 1f : 0.5f;
             break;
         }
     }
 }
        protected override void GenerateButtons()
        {
            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);
                }
            }

            GameObject[] buttonSet = null;
            switch (buttonTypes.Count)
            {
            case 1:
                buttonSet = oneButtonSet;
                break;

            case 2:
                buttonSet = twoButtonSet;
                break;

            /*case 3:
             *  buttonSet = threeButtonSet;
             *  break;*/

            default:
                UnityEngine.Debug.LogError("This dialog only supports up to 2 buttons - you've tried to create " + buttonTypes.Count);
                return;
            }

            for (int i = 0; i < buttonSet.Length; i++)
            {
                CompoundButtonText text = buttonSet[i].GetComponent <CompoundButtonText>();
                text.Text = buttonTypes[i].ToString();
                buttonSet[i].AddComponent <SimpleDialogButton>().Type = buttonTypes[i];
                Registerinteractable(buttonSet[i].gameObject);
                buttonSet[i].gameObject.SetActive(true);
            }
        }
Esempio n. 9
0
        public override void OnInspectorGUI()
        {
            CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target;

            bool microphoneEnabled = PlayerSettings.WSA.GetCapability(PlayerSettings.WSACapability.Microphone);

            if (!microphoneEnabled)
            {
                HUXEditorUtils.WarningMessage("Microphone capability not present. Speech recognition will be disabled.", "Enable Microphone Capability", EnableMicrophone);
                HUXEditorUtils.SaveChanges(target);
                return;
            }

            HUXEditorUtils.BeginSectionBox("Keyword source");
            speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)EditorGUILayout.EnumPopup(speechButton.KeywordSource);
            CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>();

            switch (speechButton.KeywordSource)
            {
            case CompoundButtonSpeech.KeywordSourceEnum.ButtonText:
            default:
                if (text == null)
                {
                    HUXEditorUtils.ErrorMessage("No CompoundButtonText component found.", AddText);
                }
                else if (string.IsNullOrEmpty(text.Text))
                {
                    HUXEditorUtils.WarningMessage("No keyword found in button text.");
                }
                else
                {
                    EditorGUILayout.LabelField("Keyword: " + text.Text);
                }
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride:
                speechButton.Keyword = EditorGUILayout.TextField(speechButton.Keyword);
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.None:
                HUXEditorUtils.DrawSubtleMiniLabel("(Speech control disabled)");
                break;
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(target);
        }
Esempio n. 10
0
        protected override void DrawCustomFooter()
        {
            ButtonTextProfile  textProfile = (ButtonTextProfile)target;
            CompoundButtonText textButton  = (CompoundButtonText)targetComponent;

            if (textButton == null || !textButton.OverrideOffset)
            {
                switch (textProfile.Anchor)
                {
                case TextAnchor.LowerCenter:
                    textProfile.AnchorLowerCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerCenterOffset);
                    break;

                case TextAnchor.LowerLeft:
                    textProfile.AnchorLowerLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerLeftOffset);
                    break;

                case TextAnchor.LowerRight:
                    textProfile.AnchorLowerRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerRightOffset);
                    break;

                case TextAnchor.MiddleCenter:
                    textProfile.AnchorMiddleCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleCenterOffset);
                    break;

                case TextAnchor.MiddleLeft:
                    textProfile.AnchorMiddleLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleLeftOffset);
                    break;

                case TextAnchor.MiddleRight:
                    textProfile.AnchorMiddleRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleRightOffset);
                    break;

                case TextAnchor.UpperCenter:
                    textProfile.AnchorUpperCenterOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperCenterOffset);
                    break;

                case TextAnchor.UpperLeft:
                    textProfile.AnchorUpperLeftOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperLeftOffset);
                    break;

                case TextAnchor.UpperRight:
                    textProfile.AnchorUpperRightOffset = UnityEditor.EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperRightOffset);
                    break;
                }
            }
        }
Esempio n. 11
0
        protected override void DrawCustomFooter()
        {
            CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target;

            bool microphoneEnabled = UnityEditor.PlayerSettings.WSA.GetCapability(UnityEditor.PlayerSettings.WSACapability.Microphone);

            if (!microphoneEnabled)
            {
                DrawWarning("Microphone capability not present. Speech recognition will be disabled.");
                return;
            }

            UnityEditor.EditorGUILayout.LabelField("Keyword source", UnityEditor.EditorStyles.miniBoldLabel);
            speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)UnityEditor.EditorGUILayout.EnumPopup(speechButton.KeywordSource);
            CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>();

            switch (speechButton.KeywordSource)
            {
            case CompoundButtonSpeech.KeywordSourceEnum.ButtonText:
            default:
                if (text == null)
                {
                    DrawError("No CompoundButtonText component found.");
                }
                else if (string.IsNullOrEmpty(text.Text))
                {
                    DrawWarning("No keyword found in button text.");
                }
                else
                {
                    UnityEditor.EditorGUILayout.LabelField("Keyword: " + text.Text);
                }
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride:
                speechButton.Keyword = UnityEditor.EditorGUILayout.TextField(speechButton.Keyword);
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.None:
                UnityEditor.EditorGUILayout.LabelField("(Speech control disabled)", UnityEditor.EditorStyles.miniBoldLabel);
                break;
            }
        }
        /// <summary>
        /// Generates a button based on type
        /// Sets button text based on type
        /// </summary>
        /// <param name="buttonType"></param>
        protected virtual GameObject GenerateButton(ButtonTypeEnum buttonType)
        {
            GameObject buttonGo = GameObject.Instantiate(buttonPrefab, buttonParent) as GameObject;
            // Set the text
            CompoundButtonText text = buttonGo.GetComponent <CompoundButtonText>();

            if (text != null)
            {
                text.Text = buttonType.ToString();
            }
            // Add the dialog button component
            SimpleDialogButton simpleDialogButton = buttonGo.GetComponent <SimpleDialogButton>();

            if (simpleDialogButton == null)
            {
                simpleDialogButton = buttonGo.AddComponent <SimpleDialogButton>();
            }
            simpleDialogButton.Type = buttonType;
            return(buttonGo);
        }
Esempio n. 13
0
        public override void OnInspectorGUI()
        {
            CompoundButtonSpeech speechButton = (CompoundButtonSpeech)target;

            HUXEditorUtils.BeginSectionBox("Keyword source");
            speechButton.KeywordSource = (CompoundButtonSpeech.KeywordSourceEnum)EditorGUILayout.EnumPopup(speechButton.KeywordSource);
            CompoundButtonText text = speechButton.GetComponent <CompoundButtonText>();

            switch (speechButton.KeywordSource)
            {
            case CompoundButtonSpeech.KeywordSourceEnum.ButtonText:
            default:
                if (text == null)
                {
                    HUXEditorUtils.ErrorMessage("No CompoundButtonText component found.", AddText);
                }
                else if (string.IsNullOrEmpty(text.Text))
                {
                    HUXEditorUtils.WarningMessage("No keyword found in button text.");
                }
                else
                {
                    EditorGUILayout.LabelField("Keyword: " + text.Text);
                }
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.LocalOverride:
                speechButton.Keyword = EditorGUILayout.TextField(speechButton.Keyword);
                break;

            case CompoundButtonSpeech.KeywordSourceEnum.None:
                HUXEditorUtils.DrawSubtleMiniLabel("(Speech control disabled)");
                break;
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(target);
        }
Esempio n. 14
0
        public void Start()
        {
            if (KeywordSource == KeywordSourceEnum.None)
            {
                return;
            }

            string keyWord = string.Empty;

            switch (KeywordSource)
            {
            case KeywordSourceEnum.ButtonText:
            default:
                CompoundButtonText text = GetComponent <CompoundButtonText>();
                keyWord = text.Text;
                break;

            case KeywordSourceEnum.LocalOverride:
                keyWord = Keyword;
                break;
            }

            KeywordManager.Instance.AddKeyword(keyWord, new KeywordManager.KeywordRecognizedDelegate(KeywordHandler), ConfidenceLevel);
        }
Esempio n. 15
0
        public override void OnInspectorGUI()
        {
            CompoundButtonText textButton = (CompoundButtonText)target;

            textAreaLabel          = new GUIStyle(EditorStyles.textArea);
            textAreaLabel.fontSize = 32;

            GUI.color = Color.white;

            textButton.DisableText = EditorGUILayout.Toggle("Disable text", textButton.DisableText);
            if (textButton.DisableText)
            {
                HUXEditorUtils.SaveChanges(target);
                return;
            }

            textButton.TextProfile = HUXEditorUtils.DrawProfileField <ButtonTextProfile>(textButton.TextProfile);

            if (textButton.TextProfile == null)
            {
                HUXEditorUtils.SaveChanges(target);
                return;
            }

            textButton.TextMesh = HUXEditorUtils.DropDownComponentField <TextMesh>("Text mesh", textButton.TextMesh, textButton.transform);

            //textButton.TextMesh = (TextMesh)EditorGUILayout.ObjectField("Text mesh", textButton.TextMesh, typeof(TextMesh), true);

            if (textButton.TextMesh == null)
            {
                GUI.color = HUXEditorUtils.ErrorColor;
                EditorGUILayout.LabelField("You must select a text mesh object.");
                HUXEditorUtils.SaveChanges(target);
                return;
            }

            HUXEditorUtils.BeginSectionBox("Overrides");
            EditorGUILayout.BeginHorizontal();
            textButton.OverrideFontStyle = EditorGUILayout.Toggle("Font style", textButton.OverrideFontStyle);
            if (textButton.OverrideFontStyle)
            {
                textButton.Style = (FontStyle)EditorGUILayout.EnumPopup(textButton.Style);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            textButton.OverrideAnchor = EditorGUILayout.Toggle("Text anchor", textButton.OverrideAnchor);
            if (textButton.OverrideAnchor)
            {
                textButton.Anchor = (TextAnchor)EditorGUILayout.EnumPopup(textButton.Anchor);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            textButton.OverrideSize = EditorGUILayout.Toggle("Text size", textButton.OverrideSize);
            if (textButton.OverrideSize)
            {
                textButton.Size = EditorGUILayout.IntField(textButton.Size);
            }
            EditorGUILayout.EndHorizontal();

            EditorGUILayout.BeginHorizontal();
            textButton.OverrideOffset = EditorGUILayout.Toggle("Offset", textButton.OverrideOffset);
            if (textButton.OverrideOffset)
            {
                EditorGUILayout.LabelField("(You may now manually adjust the offset of the text)", EditorStyles.miniLabel);
            }
            EditorGUILayout.EndHorizontal();

            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.BeginSectionBox("Button text");

            textButton.Text = EditorGUILayout.TextArea(textButton.Text, textAreaLabel);

            HUXEditorUtils.EndSectionBox();
            //textButton.Alpha = EditorGUILayout.Slider("Text transparency", textButton.Alpha, 0f, 1f);

            HUXEditorUtils.DrawProfileInspector(textButton.TextProfile, textButton);

            HUXEditorUtils.SaveChanges(target);
        }
Esempio n. 16
0
    // Create the customer menu based on productId
    public async Task CreateCustomerMenu(string id)
    {
        // Populate accounts list using web api call
        List <Account> accounts = await DataController.getCustomers(id);

        parent = gameObject;

        // Save position and scale and minize the menu untill loading is done
        //Vector3 currentLocation = GameObject.Find("MenuObject").transform.localPosition;
        transform.localScale = new Vector3(1f, 1f, 1f);
        Vector3 currentScale = transform.localScale;

        transform.localScale = new Vector3(0f, 0f, 0f);

        // Setting up ObjectCollection on parent -- takes care of placement in relation to other gameObjects
        ObjectCollection buttonCollection = parent.GetComponent <ObjectCollection>();

        buttonCollection.CellWidth   = 0.45f;
        buttonCollection.CellHeight  = 0.45f;
        buttonCollection.SurfaceType = SurfaceTypeEnum.Plane;
        buttonCollection.Rows        = 1;

        // Tagging the menu as a customer menu
        gameObject.tag = "CustomerMenu";

        // Sizing the box collider based on amount of customers
        parent.GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * accounts.Count, buttonCollection.CellHeight - 0.2f, 0.1f);
        GameObject.Find("MenuObject").GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * accounts.Count, buttonCollection.CellHeight - 0.2f, 0.1f);

        // Iterate through the accounts list
        foreach (Account a in accounts)
        {
            Debug.Log(name);

            // Instantiate the prefab button
            GameObject button = Instantiate(Resources.Load("HolographicButton")) as GameObject;
            button.name = id + "/" + a.id;
            Debug.Log(button.name);

            // Load image from url -- This needs to be changed in CRM (No url field)
            //StartCoroutine(loadImageFromUrl(p.productLogo, button));

            // Change the button text
            CompoundButtonText buttonText = button.GetComponent <CompoundButtonText>();
            buttonText.Text         = a.naam;
            buttonText.Size         = 75;
            buttonText.OverrideSize = true;
            buttonText.Style        = FontStyle.Bold;

            // Initialize Receiver
            receiver = parent.GetComponent <InteractionReceiver>();

            // Add button to the receiver
            receiver.interactables.Add(button);

            // Add the button to the menu
            button.transform.SetParent(parent.transform);
            Debug.Log(parent.transform.childCount);

            // Scale the button
            button.transform.localScale = new Vector3(currentScale.x * 3f, currentScale.x * 3f, 1f);
            counter++;
        }
        // Update button placements
        buttonCollection.UpdateCollection();

        // Scale the menu
        //GameObject.Find("MenuObject").transform.localPosition = currentLocation;
        transform.localScale = new Vector3(1f, 1f, 1f);
        if (WorldAnchorManager.Instance != null)
        {
            // Add world anchor when object placement is done.
            WorldAnchorManager.Instance.AttachAnchor(GameObject.Find("MenuObject"));
        }
    }
Esempio n. 17
0
 void Start()
 {
     buttonText = gameObject.GetComponent <HoloToolkit.Unity.Buttons.CompoundButtonText>();
 }
Esempio n. 18
0
 void Start()
 {
     collider   = gameObject.GetComponent <BoxCollider>();
     buttonText = GetComponent <CompoundButtonText>();
 }
Esempio n. 19
0
        public override void OnInspectorGUI()
        {
            SimpleMenuCollection menu = (SimpleMenuCollection)target;

            HUXEditorUtils.BeginSectionBox("Menu settings");

            menu.DisplayTitle = EditorGUILayout.Toggle("Display Title", menu.DisplayTitle);
            if (menu.DisplayTitle)
            {
                //menu.TitleText.font = (Font)EditorGUILayout.ObjectField("Title font", menu.TitleText.font, typeof(Font), false);
                menu.Title     = EditorGUILayout.TextArea(menu.Title);
                menu.TitleText = HUXEditorUtils.DropDownComponentField <TextMesh>("Title TextMesh", menu.TitleText, menu.transform);
            }

            menu.DisplaySubtitle = EditorGUILayout.Toggle("Display Subtitle", menu.DisplaySubtitle);
            if (menu.DisplaySubtitle)
            {
                //menu.TitleText.font = (Font)EditorGUILayout.ObjectField("Title font", menu.TitleText.font, typeof(Font), false);
                menu.Subtitle     = EditorGUILayout.TextArea(menu.Subtitle);
                menu.SubtitleText = HUXEditorUtils.DropDownComponentField <TextMesh>("Subtitle TextMesh", menu.SubtitleText, menu.transform);
            }
            menu.ButtonPrefab     = (GameObject)EditorGUILayout.ObjectField("Button prefab", menu.ButtonPrefab, typeof(GameObject), false);
            menu.ParentCollection = HUXEditorUtils.DropDownComponentField <ObjectCollection>("Collection parent", menu.ParentCollection, menu.transform);

            if (menu.ButtonPrefab == null)
            {
                HUXEditorUtils.ErrorMessage("You must specify a button prefab");
                HUXEditorUtils.EndSectionBox();
                return;
            }

            if (menu.ParentCollection == null)
            {
                HUXEditorUtils.ErrorMessage("This menu needs a collection component to work", AddCollection, "Fix");
                HUXEditorUtils.EndSectionBox();
                return;
            }

            bool showIcon = false;
            bool showText = false;

            CompoundButtonIcon icon = menu.ButtonPrefab.GetComponent <CompoundButtonIcon>();

            showIcon = icon != null;


            CompoundButtonText text = menu.ButtonPrefab.GetComponent <CompoundButtonText>();

            showText = text != null;

            ButtonIconProfile profile = null;

            if (icon != null)
            {
                profile = icon.IconProfile;
            }

            HUXEditorUtils.BeginSubSectionBox("Buttons");
            HUXEditorUtils.DrawSubtleMiniLabel("Up to " + SimpleMenuCollection.MaxButtons + " allowed. Un-named buttons will be ignored.");

            SimpleMenuCollectionButton[] buttons          = menu.Buttons;
            HashSet <string>             buttonNamesSoFar = new HashSet <string>();
            int numButtons = 0;

            for (int i = 0; i < buttons.Length; i++)
            {
                if (!buttons[i].IsEmpty)
                {
                    numButtons++;
                }
                DrawButtonEditor(buttons[i], showIcon, showText, profile, "buttons", i, buttonNamesSoFar);
            }
            HUXEditorUtils.EndSubSectionBox();

            menu.EditorRefreshButtons();

            HUXEditorUtils.BeginSubSectionBox("Menu preview");
            HUXEditorUtils.DrawSubtleMiniLabel("An approximation of what the menu will look like.");

            List <SimpleMenuCollectionButton> buttonsList = new List <SimpleMenuCollectionButton>(buttons);

            buttonsList.Sort(delegate(SimpleMenuCollectionButton b1, SimpleMenuCollectionButton b2) { return(b1.Index.CompareTo(b2.Index)); });

            scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition, false, false, GUILayout.MinHeight(previewButtonSizeY * numButtons + 50f));
            EditorGUILayout.BeginVertical();
            bool drewOneButton = false;

            foreach (SimpleMenuCollectionButton button in buttonsList)
            {
                drewOneButton |= DrawPreviewButton(button, showText);
            }
            if (!drewOneButton)
            {
                HUXEditorUtils.WarningMessage("This state has no buttons due to the options you've chosen. It won't be permitted during play mode.");
            }
            EditorGUILayout.EndVertical();
            EditorGUILayout.EndScrollView();

            HUXEditorUtils.EndSubSectionBox();

            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.SaveChanges(menu);
        }
        public override void OnInspectorGUI()
        {
            ButtonTextProfile  textProfile = (ButtonTextProfile)target;
            CompoundButtonText textButton  = (CompoundButtonText)targetComponent;

            HUXEditorUtils.BeginProfileBox();

            HUXEditorUtils.BeginSectionBox("Text properties");

            textProfile.Font      = (Font)EditorGUILayout.ObjectField("Font", textProfile.Font, typeof(Font), false);
            textProfile.Alignment = (TextAlignment)EditorGUILayout.EnumPopup("Alignment", textProfile.Alignment);
            if (textButton == null || !textButton.OverrideAnchor)
            {
                textProfile.Anchor = (TextAnchor)EditorGUILayout.EnumPopup("Anchor", textProfile.Anchor);
            }
            if (textButton == null || !textButton.OverrideFontStyle)
            {
                textProfile.Style = (FontStyle)EditorGUILayout.EnumPopup("Style", textProfile.Style);
            }
            if (textButton == null || !textButton.OverrideSize)
            {
                textProfile.Size = EditorGUILayout.IntField("Size", textProfile.Size);
            }
            textProfile.Color = EditorGUILayout.ColorField(textProfile.Color);

            HUXEditorUtils.EndSectionBox();


            HUXEditorUtils.BeginSectionBox("Text Offset (based on anchor setting)");
            if (textButton == null || !textButton.OverrideOffset)
            {
                switch (textProfile.Anchor)
                {
                case TextAnchor.LowerCenter:
                    textProfile.AnchorLowerCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerCenterOffset);
                    break;

                case TextAnchor.LowerLeft:
                    textProfile.AnchorLowerLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerLeftOffset);
                    break;

                case TextAnchor.LowerRight:
                    textProfile.AnchorLowerRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorLowerRightOffset);
                    break;

                case TextAnchor.MiddleCenter:
                    textProfile.AnchorMiddleCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleCenterOffset);
                    break;

                case TextAnchor.MiddleLeft:
                    textProfile.AnchorMiddleLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleLeftOffset);
                    break;

                case TextAnchor.MiddleRight:
                    textProfile.AnchorMiddleRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorMiddleRightOffset);
                    break;

                case TextAnchor.UpperCenter:
                    textProfile.AnchorUpperCenterOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperCenterOffset);
                    break;

                case TextAnchor.UpperLeft:
                    textProfile.AnchorUpperLeftOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperLeftOffset);
                    break;

                case TextAnchor.UpperRight:
                    textProfile.AnchorUpperRightOffset = EditorGUILayout.Vector3Field("Anchor (" + textProfile.Anchor.ToString() + ")", textProfile.AnchorUpperRightOffset);
                    break;
                }
            }
            HUXEditorUtils.EndSectionBox();

            HUXEditorUtils.EndProfileBox();

            HUXEditorUtils.SaveChanges(target, serializedObject);
        }
Esempio n. 21
0
    // Creates the Product menu
    public async Task CreateProductMenu()
    {
        // Populate products list with web api get call
        List <Product> products = await DataController.getProducts();

        parent = gameObject;

        // Save position and scale and minize the menu untill loading is done
        //Vector3 currentLocation = GameObject.Find("MenuObject").transform.localPosition;
        transform.localScale = new Vector3(1f, 1f, 1f);
        Vector3 currentScale = transform.localScale;

        transform.localScale = new Vector3(0f, 0f, 0f);

        // Setting up ObjectCollection on parent -- takes care of placement in relation to other gameObjects
        ObjectCollection buttonCollection = parent.GetComponent <ObjectCollection>();

        buttonCollection.CellWidth   = 0.45f;
        buttonCollection.CellHeight  = 0.45f;
        buttonCollection.SurfaceType = SurfaceTypeEnum.Plane;
        buttonCollection.Rows        = 1; // Change this based on amount of products? !!

        // Tag the menu as a product menu
        gameObject.tag = "ProductMenu";

        // Size the collider based on the size of product list
        parent.GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * products.Count, buttonCollection.CellHeight - 0.2f, 0.1f);
        GameObject.Find("MenuObject").GetComponent <BoxCollider>().size = new Vector3(buttonCollection.CellWidth * products.Count, buttonCollection.CellHeight - 0.2f, 0.1f);

        // Iterate through the products list
        foreach (Product p in products)
        {
            Debug.Log(name);

            // Instantiate the prefab button
            GameObject button = Instantiate(Resources.Load("HolographicButton")) as GameObject;
            button.name = p.productId;
            Debug.Log(button.name);

            // Load the image from url and scale it
            StartCoroutine(loadImageFromUrl(p.productLogo, button));

            // Change the button text value and style
            CompoundButtonText buttonText = button.GetComponent <CompoundButtonText>();
            buttonText.Text         = p.productNaam;
            buttonText.Size         = 75;
            buttonText.OverrideSize = true;
            buttonText.Style        = FontStyle.Bold;

            // Initialize Receiver
            receiver = parent.GetComponent <InteractionReceiver>();

            // Add button to the receiver
            receiver.interactables.Add(button);

            // Add the button to the menu
            button.transform.SetParent(parent.transform);
            Debug.Log(parent.transform.childCount);
            Debug.Log(p.productLogo);

            // Scale the button
            button.transform.localScale = new Vector3(currentScale.x * 3f, currentScale.x * 3f, 1f);

            counter++;
        }
        // Update the button placements
        buttonCollection.UpdateCollection();

        // Scale the menu
        //GameObject.Find("MenuObject").transform.localPosition = currentLocation;
        transform.localScale = new Vector3(1f, 1f, 1f);
        if (WorldAnchorManager.Instance != null)
        {
            // Add world anchor when object placement is done.
            WorldAnchorManager.Instance.AttachAnchor(GameObject.Find("MenuObject"));
        }
    }
 void Start()
 {
     toolbar    = FindObjectOfType <Toolbar>();
     tagalong   = toolbar.EnsureComponent <Tagalong>();
     buttonText = gameObject.GetComponent <CompoundButtonText>();
 }