public TextGenerator(string path, string fontName, uint fontSize = 12) { if (_textPs == null) { LoadProgramShader(); } FontName = fontName; FontSize = fontSize; SharpFont.Library fontLib = new SharpFont.Library(); SharpFont.Face fontFace = new SharpFont.Face(fontLib, path); fontFace.SetPixelSizes(0, FontSize); GL.PixelStore(PixelStoreParameter.UnpackAlignment, 1); for (char c = (char)0x20; c <= (char)0x7E; c++) { fontFace.LoadChar(c, LoadFlags.Render, LoadTarget.Normal); Texture texture = Texture.CreateTexture( fontFace.Glyph.Bitmap.Width, fontFace.Glyph.Bitmap.Rows, PixelInternalFormat.R8, PixelFormat.Red, fontFace.Glyph.Bitmap.Buffer); Character character = new Character( texture.ID, new Vector2(fontFace.Glyph.Bitmap.Width, fontFace.Glyph.Bitmap.Rows), new Vector2(fontFace.Glyph.BitmapLeft, fontFace.Glyph.BitmapTop), (int)fontFace.Glyph.Advance.X); _characters.Add(c, character); } fontFace.Dispose(); fontLib.Dispose(); vao = VAO.Create(); vao.LinkPS(_textPs); vbo = VBO.Create <float>(vertices.Length, 4, "vertex"); indices = new IndicesCollection(); indices.Add(4, vertices.Length); vao.AddVBuff(vbo); vao.AddIndicesCollection(indices); }
public void ShowIndice() { IndicesCollection ic = IndicesCollection.loadData(path); indice.text = ""; foreach (var item in ic.indicesCollection) { if (index.text == item.id) { indice.text = item.content; ficheIndice.SetActive(true); } } index.text = ""; }
public static IndicesCollection loadData(string path) { /*XmlSerializer serializer = new XmlSerializer(typeof(IndicesCollection)); * using (FileStream stream = new FileStream(path, FileMode.Open)) * { * IndicesCollection indices = serializer.Deserialize(stream) as IndicesCollection; * return indices; * }*/ TextAsset monxml = Resources.Load <TextAsset>(path); XmlSerializer serializer = new XmlSerializer(typeof(IndicesCollection)); StringReader reader = new StringReader(monxml.text); IndicesCollection indices = serializer.Deserialize(reader) as IndicesCollection; return(indices); }
// Start is called before the first frame update void Start() { IndicesCollection ic = IndicesCollection.loadData(path); foreach (Indice item in ic.indicesCollection) { //Debug.Log("--// id: " + item.id + "\n contenu = " + item.content + "//--"); if (item.id == "99") { Debug.Log(item.content); } } /*data = IndicesCollection.loadData(Application.persistentDataPath + "/Indices.xml"); * Debug.Log(Application.persistentDataPath); * * foreach (var item in data.indicesCollection) * { * Debug.Log("--id: " + item.id + "\n contenu = " + item.content + "--"); * * } */ }