static void CreateLabelObject() { GameObject labelGO = new GameObject("Label"); exUILabel label = labelGO.AddComponent <exUILabel>(); // create Font GameObject fontGO = new GameObject("Font"); exSpriteFont font = fontGO.AddComponent <exSpriteFont>(); font.text = ""; label.font = font; fontGO.transform.parent = labelGO.transform; label.width = 50.0f; label.height = 20.0f; // Selection.activeObject = labelGO; }
// ------------------------------------------------------------------ // Desc: // ------------------------------------------------------------------ public override void OnInspectorGUI() { exUILabel editTarget = target as exUILabel; // ======================================================== // Base GUI // ======================================================== base.OnInspectorGUI(); GUILayout.Space(20); // ======================================================== // // ======================================================== serializedObject.Update(); // font EditorGUILayout.PropertyField(fontProp); // autoSize EditorGUILayout.PropertyField(autoSizeProp, new GUIContent("Auto Size")); editTarget.autoSize = autoSizeProp.boolValue; // use Multiline if (useMultilineProp != null) { EditorGUILayout.PropertyField(useMultilineProp, new GUIContent("Use Multiline")); if (editTarget.font) { editTarget.font.useMultiline = useMultilineProp.boolValue; } } // text if (useMultilineProp != null && useMultilineProp.boolValue) { EditorGUILayout.LabelField("Text"); textProp.stringValue = EditorGUILayout.TextArea(textProp.stringValue, EditorGUIUtility.GetBuiltinSkin(EditorSkin.Inspector).textArea); } else { EditorGUILayout.PropertyField(textProp, new GUIContent("Text")); } editTarget.text = textProp.stringValue; if (editTarget.autoSize) { if (editTarget.font) { editTarget.font.Commit(); widthProp.floatValue = editTarget.font.boundingRect.width; heightProp.floatValue = editTarget.font.boundingRect.height; } } // alignment EditorGUILayout.LabelField("Alignment", ""); GUILayout.BeginHorizontal(); GUILayout.Space(30); alignmentProp.enumValueIndex = GUILayout.SelectionGrid(alignmentProp.enumValueIndex, anchorTexts, 3, GUILayout.Width(80)); editTarget.alignment = (exPlane.Anchor)alignmentProp.enumValueIndex; GUILayout.EndHorizontal(); serializedObject.ApplyModifiedProperties(); }