Skip to content

Instantly share code, notes, and snippets.

@peroon
Created November 28, 2016 10:58
Show Gist options
  • Select an option

  • Save peroon/d41b2be2a091da9eb4aa68ae9820fb78 to your computer and use it in GitHub Desktop.

Select an option

Save peroon/d41b2be2a091da9eb4aa68ae9820fb78 to your computer and use it in GitHub Desktop.
using UnityEngine;
using UnityEditor;
using UnityEngine.UI;
using System.Collections;
using DL;
// Textで作っちゃってDLTextに移行するのが面倒なときに使う
public class TextToDLText {
[MenuItem("Tools/k-ishibashi/TextToDLText")]
static void Swap(){
foreach (var go in Selection.gameObjects) {
var textComponent = go.GetComponent<Text> ();
Debug.Log (textComponent.text);
GameObject.DestroyImmediate (go.GetComponent<Text> ());
var dlText = go.AddComponent<Imas.DLText> ();
// コピー
dlText.font = textComponent.font; // フォント
dlText.fontSize = textComponent.fontSize; // フォントサイズ
dlText.color = textComponent.color; // 色
dlText.alignment = textComponent.alignment; // センタリング
dlText.lineSpacing = textComponent.lineSpacing; // スペース
// テキストキー
dlText.TextKey = textComponent.text;
dlText.SetText(textComponent.text);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment