Ejemplo n.º 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 DrawIconCharEditor(bool showComponents, ButtonIconSet iconSet)
        {
            if (showComponents)
            {
                EditorGUILayout.PropertyField(iconCharLabelProp);
            }

            uint currentIconChar = 0;

            if (iconCharProp.longValue > 0)
            {
                currentIconChar = (uint)iconCharProp.longValue;
            }
            else
            {
                if (iconCharLabelProp != null)
                {
                    SerializedObject   tmpObject      = new SerializedObject(iconCharLabelProp.objectReferenceValue);
                    SerializedProperty tmpTextProp    = tmpObject.FindProperty("m_text");
                    string             iconCharString = tmpTextProp.stringValue;
                    currentIconChar = ButtonIconSet.ConvertCharStringToUInt32(iconCharString);
                }
                else
                {
                    EditorGUILayout.HelpBox("This button has no icon char renderer assigned.", MessageType.Warning);
                    return;
                }
            }

            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(iconSetProp);
            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;
            }

            uint newIconChar;
            bool foundChar;

            if (iconSet.EditorDrawCharIconSelector(currentIconChar, out foundChar, out newIconChar, 1))
            {
                iconCharProp.longValue = newIconChar;
                SerializedObject   iconSetObject    = new SerializedObject(iconSet);
                SerializedProperty charIconFontProp = iconSetObject.FindProperty("charIconFont");
                iconFontProp.objectReferenceValue = charIconFontProp.objectReferenceValue;
                cb.SetCharIcon(newIconChar);

                if (!foundChar)
                {
                    EditorGUILayout.HelpBox(missingCharIconWarningMessage, MessageType.Warning);
                }
            }
        }
Ejemplo n.º 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;
        }