Example #1
0
        public IEnumerator TestPressableButtonHololens2Prefab()
        {
            GameObject         buttonObject = InstantiateButtonFromPath(Vector3.zero, Quaternion.identity, TestButtonUtilities.PressableHoloLens2PrefabPath);
            ButtonConfigHelper bch          = buttonObject.GetComponent <ButtonConfigHelper>();

            bch.MainLabelText = "MainLabelText";
            Assert.AreEqual(bch.MainLabelText, "MainLabelText");

            bch.SeeItSayItLabelText = "SeeItSayItLabelText";
            Assert.AreEqual(bch.SeeItSayItLabelText, "SeeItSayItLabelText");

            bch.IconStyle = ButtonIconStyle.Char;
            bch.IconStyle = ButtonIconStyle.None;
            bch.IconStyle = ButtonIconStyle.Quad;
            bch.IconStyle = ButtonIconStyle.Sprite;
            bch.SeeItSayItLabelEnabled = false;
            bch.SetCharIcon(0);
            bch.SetQuadIcon(null);
            bch.SetSpriteIcon(null);
            bch.SetCharIconByName("EmptyIcon");
            bch.SetQuadIconByName("EmptyIcon");
            bch.SetSpriteIconByName("EmptyIcon");
            bch.ForceRefresh();
            bch.OnClick.AddListener(() => { Debug.Log("OnClick"); });
            bch.IconSet = null;

            yield break;
        }
        private void DrawIconQuadEditor(bool showComponents, ButtonIconSet iconSet)
        {
            if (showComponents)
            {
                EditorGUILayout.PropertyField(iconQuadRendererProp);
            }

            Texture currentIconTexture = null;

            if (iconQuadTextureProp.objectReferenceValue != null)
            {
                currentIconTexture = iconQuadTextureProp.objectReferenceValue as Texture;
            }
            else
            {
                if (iconQuadRendererProp.objectReferenceValue != null)
                {
                    currentIconTexture = ((Renderer)iconQuadRendererProp.objectReferenceValue).sharedMaterial.GetTexture(iconQuadTextureNameIDProp.stringValue);
                }
                else
                {
                    EditorGUILayout.HelpBox("This button has no icon quad renderer assigned.", MessageType.Warning);
                    return;
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(iconSetProp);

            EditorGUILayout.Space();
            if (iconSet == null)
            {
                EditorGUILayout.HelpBox("No icon set assigned. You can specify custom icons manually by assigning them to the field below:", MessageType.Info);
                EditorGUILayout.PropertyField(iconQuadTextureProp);
                return;
            }
            if (iconSet.QuadIcons == null || iconSet.QuadIcons.Length == 0)
            {
                EditorGUILayout.HelpBox("No quad icons assigned to the icon set. You can specify custom icons manually by assigning them to the field below:", MessageType.Info);
                EditorGUILayout.PropertyField(iconQuadTextureProp);
                return;
            }

            Texture newIconTexture;
            bool    foundTexture;

            if (iconSet.EditorDrawQuadIconSelector(currentIconTexture, out foundTexture, out newIconTexture, 1))
            {
                iconQuadTextureProp.objectReferenceValue = newIconTexture;
                cb.SetQuadIcon(newIconTexture);
            }

            if (!foundTexture)
            {
                EditorGUILayout.HelpBox(missingIconWarningMessage, MessageType.Warning);
                EditorGUILayout.PropertyField(iconQuadTextureProp);
            }
        }
Example #3
0
        /// <summary>
        /// Test adding a config helper to a game object and attempting to modify it.
        /// </summary>
        public IEnumerator TestAddButtonConfigHelperAtRuntime()
        {
            GameObject         newGameObject = new GameObject("ButtonTest");
            ButtonConfigHelper bch           = newGameObject.AddComponent <ButtonConfigHelper>();

            bch.MainLabelText          = "Test Text";
            bch.SeeItSayItLabelText    = "Test Text";
            bch.IconStyle              = ButtonIconStyle.Char;
            bch.IconStyle              = ButtonIconStyle.None;
            bch.IconStyle              = ButtonIconStyle.Quad;
            bch.IconStyle              = ButtonIconStyle.Sprite;
            bch.SeeItSayItLabelEnabled = false;
            bch.SetCharIcon(0);
            bch.SetQuadIcon(null);
            bch.SetSpriteIcon(null);
            bch.SetCharIconByName("EmptyIcon");
            bch.SetQuadIconByName("EmptyIcon");
            bch.SetSpriteIconByName("EmptyIcon");
            bch.ForceRefresh();
            bch.OnClick.AddListener(() => { Debug.Log("OnClick"); });
            bch.IconSet = null;

            yield break;
        }