public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var dataProperty = property.FindPropertyRelative("_data"); var isLocalisedProperty = property.FindPropertyRelative("_isLocalised"); label = EditorGUI.BeginProperty(position, label, property); var contentPosition = EditorGUI.PrefixLabel(position, label); var rowPosition = new Rect(contentPosition) { height = EditorGUIUtility.singleLineHeight }; var dataPosition = new Rect(rowPosition); dataPosition.xMax -= 20; EditorGUI.PropertyField(dataPosition, dataProperty, GUIContent.none); dataPosition.x = contentPosition.xMax - 16; dataPosition.xMax = contentPosition.xMax; isLocalisedProperty.boolValue = EditorGUI.Toggle(dataPosition, new GUIContent("", "Lets you toggle whether this is a fixed or localised test"), isLocalisedProperty.boolValue, GuiStyles.LocalisationToggleStyle); if (isLocalisedProperty.boolValue) { rowPosition.y += EditorGUIUtility.singleLineHeight + 2; var localisedText = LocaliseText.Exists(dataProperty.stringValue) ? LocaliseText.Get(dataProperty.stringValue) : "<Key not found in localisation file>"; EditorGUI.LabelField(rowPosition, localisedText); } //EditorGUI.indentLevel += 1; EditorGUI.EndProperty(); }
void Awake() { var player = GameManager.Instance.Player; if (player == null) return; var textComponent = GetComponent<Text>(); var text = LocaliseText.Exists(Key) ? LocaliseText.Get(Key) : Key; textComponent.text = string.Format(text, player.Number, player.Name, player.Description); }
void Awake() { Assert.IsNotNull(GenericGameItemManager.Instance.GenericGameItems, "GenericGameItems are not setup when referenced from ShowGenericGameItemInfo"); var genericGameItem = GenericGameItemManager.Instance.GenericGameItems.Selected; if (genericGameItem != null) { var textComponent = GetComponent<Text>(); var text = LocaliseText.Exists(Key) ? LocaliseText.Get(Key) : Key; textComponent.text = string.Format(text, genericGameItem.Number, genericGameItem.Name, genericGameItem.Description); } }
void Awake() { Assert.IsNotNull(GameManager.Instance.Characters, "Characters are not setup when referenced from ShowCharacterInfo"); var character = GameManager.Instance.Characters.Selected; if (character != null) { var _textComponent = GetComponent <Text>(); var text = LocaliseText.Exists(Key) ? LocaliseText.Get(Key) : Key; _textComponent.text = string.Format(text, character.Number, character.Name, character.Description); } }
void Awake() { Assert.IsNotNull(GameManager.Instance.Levels, "Levels are not setup when referenced from ShowLevelInfo"); var level = GameManager.Instance.Levels.Selected; if (level != null) { var textComponent = GetComponent <Text>(); var text = LocaliseText.Exists(Key) ? LocaliseText.Get(Key) : Key; textComponent.text = string.Format(text, level.Number, level.Name, level.Description); } }
void Awake() { Assert.IsNotNull(GameManager.Instance.Worlds, "Worlds are not setup when referenced from ShowWorldInfo"); var world = GameManager.Instance.Worlds.Selected; if (world != null) { var textComponent = GetComponent <Text>(); var text = LocaliseText.Exists(Key) ? LocaliseText.Get(Key) : Key; textComponent.text = string.Format(text, world.Number, world.Name, world.Description); } }
public override void OnGUI(Rect position, SerializedProperty property, GUIContent label) { var dataProperty = property.FindPropertyRelative("_data"); var isLocalisedProperty = property.FindPropertyRelative("_isLocalised"); label = EditorGUI.BeginProperty(position, label, property); var contentPosition = EditorGUI.PrefixLabel(position, label); var rowPosition = new Rect(contentPosition) { height = EditorGUIUtility.singleLineHeight }; // Don't make child fields indented var indent = EditorGUI.indentLevel; EditorGUI.indentLevel = 0; var dataPosition = new Rect(rowPosition) { width = 16 }; var isLocalised = isLocalisedProperty.boolValue = EditorGUI.Toggle(dataPosition, new GUIContent("", "Lets you toggle whether this is a fixed or localised test"), isLocalisedProperty.boolValue, GuiStyles.LocalisationToggleStyle); dataPosition.x += 20; dataPosition.xMax = rowPosition.xMax - (isLocalised ? 18 : 0); EditorGUI.PropertyField(dataPosition, dataProperty, GUIContent.none); if (isLocalised) { dataPosition.x = rowPosition.xMax - 16; dataPosition.width = 16; if (GUI.Button(dataPosition, new GUIContent("+", "Add a new localisation string"))) { LocalisationEditorWindow.ShowWindowNew(dataProperty.stringValue); } } if (isLocalisedProperty.boolValue) { rowPosition.y += EditorGUIUtility.singleLineHeight + 2; var localisedText = LocaliseText.Exists(dataProperty.stringValue) ? LocaliseText.Get(dataProperty.stringValue) : "<Key not found in localisation file>"; EditorGUI.LabelField(rowPosition, localisedText); } // Set indent back to what it was EditorGUI.indentLevel = indent; EditorGUI.EndProperty(); }