Наследование: ISysFontTexturable
Пример #1
0
 protected void OnDestroy()
 {
     material = null;
     SysFont.SafeDestroy(_createdMaterial);
     if (_texture != null)
     {
         _texture.Destroy();
         _texture = null;
     }
 }
Пример #2
0
 protected void OnDestroy()
 {
     if (_texture != null)
     {
         _texture.Destroy();
         _texture = null;
     }
     SysFont.SafeDestroy(_mesh);
     SysFont.SafeDestroy(_createdMaterial);
     _createdMaterial = null;
     _material        = null;
     _vertices        = null;
     _uv        = null;
     _triangles = null;
     _mesh      = null;
     _filter    = null;
     _renderer  = null;
 }
Пример #3
0
        public TTFTextTexturePortion ComputeGlyphBitmap(object parameters, object font, char c)
        {
            SysFontTexture tex = new SysFontTexture();
            FontSelector   fs  = (FontSelector)GetFontSelectorFromFontName((string)font);

            tex.AndroidFontName = fs.AndroidFontName;
            tex.AppleFontName   = fs.AppleFontName;
            tex.Update();

            Texture2D _texture = new Texture2D(1, 1, TextureFormat.Alpha8, false);

            //Texture2D _texture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
            _texture.hideFlags  = HideFlags.HideInInspector | HideFlags.DontSave;
            _texture.filterMode = FilterMode.Point;
            _texture.wrapMode   = TextureWrapMode.Clamp;
            int textureID = _texture.GetNativeTextureID();

            SysFont.QueueTexture("" + c,
#if UNITY_ANDROID
                                 fs.AndroidFontName
#else
#if UNITY_IPHONE
                                 fs.AppleFontName
#else
                                     ((string)font)
#endif
#endif
                                 ,
                                 12,
                                 false,                  //_isBold,
                                 false,                  //_isItalic,
                                 SysFont.Alignment.Left, //_alignment,
                                 false,
                                 2048,
                                 2048,
                                 textureID
                                 );

            int _textWidthPixels  = SysFont.GetTextWidth(textureID);
            int _textHeightPixels = SysFont.GetTextHeight(textureID);



            SysFont.UpdateQueuedTexture(textureID);
            Debug.Log(".");

            Parameters cp = parameters as Parameters;
            Material   m  = null;
            if (cp != null)
            {
                Shader shader = Shader.Find(cp.shaderName);
                if (shader == null)
                {
                    shader = Shader.Find("Mobile/Diffuse");
                }
                if (shader == null)
                {
                    shader = Shader.Find("Diffuse");
                }
                m             = new Material(shader);
                m.color       = new Color(cp.red, cp.green, cp.blue, cp.alpha);
                m.mainTexture = _texture;
            }
            else
            {
                Shader shader = Shader.Find("SysFont/Unlit Transparent");
                if (shader == null)
                {
                    shader = Shader.Find("Mobile/Diffuse");
                }
                if (shader == null)
                {
                    shader = Shader.Find("Diffuse");
                }
                m             = new Material(shader);
                m.color       = Color.black;
                m.mainTexture = _texture;
            }

            TTFTextTexturePortion p = new TTFTextTexturePortion(
                m,
                0, 0, 1, 1,
                _textWidthPixels * cp.scale, _textHeightPixels * cp.scale,
                0, 0,
                true
                );

            return(p);
        }
Пример #4
0
  protected void OnDestroy()
  {
    material = null;
    SysFont.SafeDestroy(_createdMaterial);
    if (_texture != null)
    {
      _texture.Destroy();
      _texture = null;
    }
	}
Пример #5
0
 protected void OnDestroy()
 {
     if (_texture != null)
     {
       _texture.Destroy();
       _texture = null;
     }
     SysFont.SafeDestroy(_mesh);
     SysFont.SafeDestroy(_createdMaterial);
     _createdMaterial = null;
     _material = null;
     _vertices = null;
     _uv = null;
     _triangles = null;
     _mesh = null;
     _filter = null;
     _renderer = null;
 }
        public TTFTextTexturePortion ComputeGlyphBitmap(object parameters, object font, char c)
        {
            SysFontTexture tex=new SysFontTexture();
            FontSelector fs=(FontSelector)GetFontSelectorFromFontName((string) font);
            tex.AndroidFontName=fs.AndroidFontName;
            tex.AppleFontName=fs.AppleFontName;
            tex.Update();

              Texture2D _texture = new Texture2D(1, 1, TextureFormat.Alpha8, false);
              //Texture2D _texture = new Texture2D(64, 64, TextureFormat.RGBA32, false);
              _texture.hideFlags = HideFlags.HideInInspector | HideFlags.DontSave;
              _texture.filterMode = FilterMode.Point;
              _texture.wrapMode = TextureWrapMode.Clamp;
               	 int textureID = _texture.GetNativeTextureID();

            SysFont.QueueTexture(""+c,
            #if UNITY_ANDROID
            fs.AndroidFontName
            #else
            #if UNITY_IPHONE
            fs.AppleFontName
            #else
            ((string)font)
            #endif
            #endif
            ,
            12,
            false,//_isBold,
            false,//_isItalic,
            SysFont.Alignment.Left,//_alignment,
            false,
            2048,
              		2048,
            textureID
            );

            int _textWidthPixels  = SysFont.GetTextWidth(textureID);
            int _textHeightPixels = SysFont.GetTextHeight(textureID);

            SysFont.UpdateQueuedTexture(textureID);
            Debug.Log(".");

            Parameters cp =parameters as Parameters;
            Material m=null;
            if (cp!=null) {
              Shader shader=Shader.Find(cp.shaderName);
              if (shader==null) {shader=Shader.Find("Mobile/Diffuse");}
             	  if (shader==null) {shader=Shader.Find("Diffuse");}
              m=new Material(shader);
              m.color=new Color(cp.red,cp.green,cp.blue,cp.alpha);
              m.mainTexture=_texture;
            }
            else {
              Shader shader=Shader.Find("SysFont/Unlit Transparent");
              if (shader==null) {shader=Shader.Find("Mobile/Diffuse");}
             	  if (shader==null) {shader=Shader.Find("Diffuse");}
              m=new Material(shader);
              m.color=Color.black;
              m.mainTexture=_texture;
            }

            TTFTextTexturePortion p=new TTFTextTexturePortion(
            m,
            0,0,1,1,
            _textWidthPixels * cp.scale,_textHeightPixels *cp.scale,
            0,0,
            true
            );

            return p;
        }
    public override void OnInspectorGUI()
    {
        _texture = (SysFontTexture)target;

        LookLikeControls();

        //
        // Text property
        //
        string text = string.IsNullOrEmpty(_texture.Text) ? "" : _texture.Text;

        EditorGUILayout.LabelField("Text");
        GUI.skin.textArea.wordWrap = true;
        text = EditorGUILayout.TextArea(text, GUI.skin.textArea,
        GUILayout.Height(50f));

        if (text.Equals(_texture.Text) == false)
        {
          RegisterUndo("SysFont Text Change");
          _texture.Text = text;
        }

        GUILayout.BeginHorizontal();
        {
          LookLikeControls(60f);
          EditorGUILayout.PrefixLabel("Font Size");
          //
          // FontSize property
          //
          int fontSize = EditorGUILayout.IntField(_texture.FontSize,
          GUILayout.Width(30f));
          if (fontSize != _texture.FontSize)
          {
        RegisterUndo("SysFont Font Size Change");
        _texture.FontSize = fontSize;
          }

          LookLikeControls(30f);

          //
          // IsBold property
          //
          EditorGUILayout.PrefixLabel("Bold");
          bool isBold = EditorGUILayout.Toggle(_texture.IsBold,
          GUILayout.Width(30f));
          if (isBold != _texture.IsBold)
          {
        RegisterUndo("SysFont Style Change");
        _texture.IsBold = isBold;
          }

          //
          // IsItalic property
          //
          EditorGUILayout.PrefixLabel("Italic");
          bool isItalic = EditorGUILayout.Toggle(_texture.IsItalic,
          GUILayout.Width(30f));
          if (isItalic != _texture.IsItalic)
          {
        RegisterUndo("SysFont Style Change");
        _texture.IsItalic = isItalic;
          }
        }
        GUILayout.EndHorizontal();

        LookLikeControls(100f);
        //
        // AppleFontName property
        //
        string appleFontName = EditorGUILayout.TextField("iOS/MacOSX Font",
        _texture.AppleFontName);
        if (appleFontName != _texture.AppleFontName)
        {
          RegisterUndo("SysFont Font Name Change");
          _texture.AppleFontName = appleFontName;
        }

        //
        // AndroidFontName property
        //
        string fontName = EditorGUILayout.TextField("Android Font",
        _texture.AndroidFontName);
        if (fontName != _texture.AndroidFontName)
        {
          RegisterUndo("SysFont Font Name Change");
          _texture.AndroidFontName = fontName;
        }
        LookLikeControls();

        GUILayout.BeginHorizontal();
        {
          LookLikeControls(60f);

          //
          // IsMultiLine property
          //
          bool isMultiLine = EditorGUILayout.Toggle("Multi Line",
          _texture.IsMultiLine, GUILayout.Width(80f));
          if (isMultiLine != _texture.IsMultiLine)
          {
        RegisterUndo("SysFont Is Multi Line Change");
        _texture.IsMultiLine = isMultiLine;
          }

          LookLikeControls(65f);

          //
          // MaxWidthPixels property
          //
          int maxWidthPixels = EditorGUILayout.IntField("Max Width",
          _texture.MaxWidthPixels, GUILayout.Width(110f));
          if (maxWidthPixels != _texture.MaxWidthPixels)
          {
        RegisterUndo("SysFont Max Width Pixels Change");
        _texture.MaxWidthPixels = maxWidthPixels;
          }

          //
          // MaxHeightPixels property
          //
          int maxHeightPixels = EditorGUILayout.IntField("Max Height",
          _texture.MaxHeightPixels, GUILayout.Width(110f));
          if (maxHeightPixels != _texture.MaxHeightPixels)
          {
        RegisterUndo("SysFont Max Height Pixels Change");
        _texture.MaxHeightPixels = maxHeightPixels;
          }

          LookLikeControls();
        }
        GUILayout.EndHorizontal();
    }