Exemplo n.º 1
0
 public void ActiveText()
 {
     //支持富文本
     supportRichText = true;
     //对齐几何
     alignByGeometry = true;
     if (!_InlineManager)
     {
         _InlineManager = GetComponentInParent <InlineManager>();
     }
     //启动的是 更新顶点
     SetVerticesDirty();
 }
Exemplo n.º 2
0
 /// <summary>
 /// 初始化
 /// </summary>
 protected override void OnEnable()
 {
     //
     base.OnEnable();
     //支持富文本
     supportRichText = true;
     //对齐几何
     alignByGeometry = true;
     if (!_InlineManager)
     {
         _InlineManager = GetComponentInParent <InlineManager>();
     }
     //启动的是 更新顶点
     SetVerticesDirty();
 }
    static void CreateCustomGameObject(MenuCommand menuCommand)
    {
        GameObject    go     = null;
        InlineManager inline = AssetDatabase.LoadAssetAtPath <InlineManager>("Assets/TextInlineSprite/Prefabs/TextInline.prefab");

        if (inline)
        {
            go = GameObject.Instantiate(inline).gameObject;
        }
        else
        {
            go = new GameObject();
            go.AddComponent <InlineText>();
        }
        go.name = "InlineText";
        GameObject parent = menuCommand.context as GameObject;

        if (parent == null)
        {
            parent       = new GameObject("Canvas");
            parent.layer = LayerMask.NameToLayer("UI");
            parent.AddComponent <Canvas>().renderMode = RenderMode.ScreenSpaceOverlay;
            parent.AddComponent <CanvasScaler>();
            parent.AddComponent <GraphicRaycaster>();

            EventSystem _es = GameObject.FindObjectOfType <EventSystem>();
            if (!_es)
            {
                _es = new GameObject("EventSystem").AddComponent <EventSystem>();
                _es.gameObject.AddComponent <StandaloneInputModule>();
            }
        }
        GameObjectUtility.SetParentAndAlign(go, parent);
        //注册返回事件
        Undo.RegisterCreatedObjectUndo(go, "Create " + go.name);
        Selection.activeObject = go;
    }