Exemplo n.º 1
0
        public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
        {
            label = new GUIContent(label.text);
            EditorGUI.BeginProperty(position, label, property);

            Rect objectFieldRect = position;

            objectFieldRect.height = 16;

            if (property.objectReferenceValue == null)
            {
                Rect buttonRect = position;
                buttonRect.height = 16;
                buttonRect.x      = position.width - 30;
                buttonRect.width  = 40;

                if (GUI.Button(buttonRect, "New"))
                {
                    property.objectReferenceValue = CreateNewInstance();
                }

                objectFieldRect.width -= 50;
            }
            else
            {
                Rect labelRect = position;
                labelRect.y     += 16;
                labelRect.height = 16;

                TextoData textoData = (TextoData)(property.objectReferenceValue);

                if (textoData.lines == null)
                {
                    textoData.lines = new List <TextoLine>();
                }

                TextoLine englishLine = textoData.lines.Find(x => x.language == TextoLanguage.English);

                if (englishLine != null)
                {
                    EditorGUI.LabelField(labelRect, " ", englishLine.text);
                }
                else
                {
                    EditorGUI.LabelField(labelRect, " ", "[No English text]", EditorStyles.boldLabel);
                }
            }

            EditorGUI.ObjectField(objectFieldRect, property, this.fieldInfo.FieldType, label);

            property.serializedObject.ApplyModifiedProperties();

            EditorGUI.EndProperty();
        }
Exemplo n.º 2
0
        public string GetLine(TextoLanguage language)
        {
            TextoLine line = lines.Find(x => x.language == language);

            if (line != null)
            {
                string finalText = line.text;

                finalText = finalText.Replace("<important>", string.Format("<color=#{0}>", ColorUtility.ToHtmlStringRGBA(TextoSettingsData.instance.highlightColor)));
                finalText = finalText.Replace("</important>", "</color>");

                return(finalText);
            }

            return("[No text found]");
        }