public static void AddRichText() { GameObject tGameObject = Selection.activeGameObject; if (tGameObject == null) { return; } if (WillLosePrefab(tGameObject) == false) { return; } Undo.RecordObject(tGameObject, "Add a child UI RichText"); // アンドウバッファに登録 GameObject tChild = new GameObject(GetName <UIRichText>(), typeof(RectTransform)); Transform tTransform = tChild.transform; tTransform.SetParent(tGameObject.transform, false); tTransform.localPosition = Vector3.zero; tTransform.localRotation = Quaternion.identity; tTransform.localScale = Vector3.one; UIRichText tText = tChild.AddComponent <UIRichText>(); tText.SetDefault(); tText.text = "RichText"; Selection.activeGameObject = tChild; UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); }
override protected void DrawInspectorGUI() { UIRichText tTarget = target as UIRichText; EditorGUILayout.Separator(); // 少し区切りスペース //------------------------------------------------------------------- EditorGUILayout.Separator(); // 少し区切りスペース bool tAutoSizeFitting = EditorGUILayout.Toggle("Auto Size Fitting", tTarget.autoSizeFitting); if (tAutoSizeFitting != tTarget.autoSizeFitting) { Undo.RecordObject(tTarget, "UIRichText : Auto Size Fitting Change"); // アンドウバッファに登録 tTarget.autoSizeFitting = tAutoSizeFitting; EditorUtility.SetDirty(tTarget); } }
/// <summary> /// ラベルを追加する /// </summary> /// <param name="tText">ラベルの文字列</param> /// <param name="tColor">ラベルのカラー</param> /// <returns>UIText のインスタンス</returns> public UIRichText AddRichLabel(string tText, uint tColor = 0xFFFFFFFF, int tFontSize = 0) { if (richLabel == null) { richLabel = AddView <UIRichText>(); } UIRichText tLabel = richLabel; //---------------------------------- if (tFontSize <= 0) { tFontSize = ( int )(size.y * 0.6f); } tLabel.alignment = TextAnchor.MiddleCenter; tLabel.text = tText; Font tDefaultFont = null; int tDefaultFontSize = 0; Color tDefaultColor = ARGB(tColor); bool tDefaultShadow = false; bool tDefaultOutline = true; #if UNITY_EDITOR if (Application.isPlaying == false) { // メニューから操作した場合のみ自動設定を行う DefaultSettings tDS = Resources.Load <DefaultSettings>("uGUIHelper/DefaultSettings"); if (tDS != null) { tDefaultFont = tDS.font; tDefaultFontSize = tDS.buttonLabelFontSize; tDefaultColor = tDS.buttonLabelColor; tDefaultShadow = tDS.buttonLabelShadow; tDefaultOutline = tDS.buttonLabelOutline; } } #endif if (tDefaultFont == null) { tLabel.font = Resources.GetBuiltinResource(typeof(Font), "Arial.ttf") as Font; } else { tLabel.font = tDefaultFont; } if (tDefaultFontSize == 0) { tLabel.fontSize = tFontSize; } else { tLabel.fontSize = tDefaultFontSize; } tLabel.color = tDefaultColor; tLabel.isShadow = tDefaultShadow; tLabel.isOutline = tDefaultOutline; //---------------------------------- if (isCanvasOverlay == true) { tLabel.material = Resources.Load <Material>("uGUIHelper/Shaders/UI-Overlay-Default"); } return(tLabel); }
override protected void DrawInspectorGUI() { UIButton tTarget = target as UIButton; EditorGUILayout.Separator(); // 少し区切りスペース //------------------------------------------------------------------- // アトラススプライトの表示 DrawAtlas(tTarget); // マテリアル選択 DrawMaterial(tTarget); //------------------------------------------------------------------- EditorGUILayout.Separator(); // 少し区切りスペース UIText tLabel = EditorGUILayout.ObjectField("Label", tTarget.label, typeof(UIText), true) as UIText; if (tLabel != tTarget.label) { Undo.RecordObject(tTarget, "UIButton : Label Change"); // アンドウバッファに登録 tTarget.label = tLabel; EditorUtility.SetDirty(tTarget); } UIRichText tRichLabel = EditorGUILayout.ObjectField("RichLabel", tTarget.richLabel, typeof(UIRichText), true) as UIRichText; if (tRichLabel != tTarget.richLabel) { Undo.RecordObject(tTarget, "UIButton : Rich Label Change"); // アンドウバッファに登録 tTarget.richLabel = tRichLabel; EditorUtility.SetDirty(tTarget); } //#if TextMeshPro UITextMesh tLabelMesh = EditorGUILayout.ObjectField("LabelMesh", tTarget.labelMesh, typeof(UITextMesh), true) as UITextMesh; if (tLabelMesh != tTarget.labelMesh) { Undo.RecordObject(tTarget, "UIButton : Label Mesh Change"); // アンドウバッファに登録 tTarget.labelMesh = tLabelMesh; EditorUtility.SetDirty(tTarget); } //#endif UIImage tDisableMask = EditorGUILayout.ObjectField("DisableMask", tTarget.disableMask, typeof(UIImage), true) as UIImage; if (tDisableMask != tTarget.disableMask) { Undo.RecordObject(tTarget, "UIButton : Disable Mask Change"); // アンドウバッファに登録 tTarget.disableMask = tDisableMask; EditorUtility.SetDirty(tTarget); } bool tClickTransitionEnabled = EditorGUILayout.Toggle("Click Transition Enabled", tTarget.clickTransitionEnabled); if (tClickTransitionEnabled != tTarget.clickTransitionEnabled) { Undo.RecordObject(tTarget, "UIButton : Click Transition Enabled Change"); // アンドウバッファに登録 tTarget.clickTransitionEnabled = tClickTransitionEnabled; EditorUtility.SetDirty(tTarget); } bool tWaitForTransition = EditorGUILayout.Toggle("Wait For Transition", tTarget.waitForTransition); if (tWaitForTransition != tTarget.waitForTransition) { Undo.RecordObject(tTarget, "UIButton : Wait For Transition Change"); // アンドウバッファに登録 tTarget.waitForTransition = tWaitForTransition; EditorUtility.SetDirty(tTarget); } bool tColorTransmission = EditorGUILayout.Toggle("Color Transmission", tTarget.colorTransmission); if (tColorTransmission != tTarget.colorTransmission) { Undo.RecordObject(tTarget, "UIButton : Color Transmission Change"); // アンドウバッファに登録 tTarget.colorTransmission = tColorTransmission; EditorUtility.SetDirty(tTarget); } EditorGUILayout.Separator(); // 少し区切りスペース bool tSetPivotToCenter = EditorGUILayout.Toggle("Set Pivot To Center", tTarget.setPivotToCenter); if (tSetPivotToCenter != tTarget.setPivotToCenter) { Undo.RecordObject(tTarget, "UIButton : Set Pivot To Center Change"); // アンドウバッファに登録 tTarget.setPivotToCenter = tSetPivotToCenter; EditorUtility.SetDirty(tTarget); } }