Script interface for.

Inheritance: UnityEngine.Object
Ejemplo n.º 1
0
		/**
		 * Get default font.
		 */
		public static Font DefaultFont()
		{
			if(_defaultFont == null)
				_defaultFont = (Font) Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");

			return _defaultFont;
		}
		internal UguiNovelTextGeneratorAddtionalRuby( List<UguiNovelTextCharacter> characters, int index, Font rubyFont, float rubySizeScale)
		{
			UguiNovelTextCharacter original = characters[index];
			int rubySize = Mathf.CeilToInt(rubySizeScale * original.FontSize);
			stringData.Add(original);
			for (int i = index + 1; i < characters.Count; ++i)
			{
				UguiNovelTextCharacter c = characters[i];
				if (!c.CustomInfo.IsRuby || c.CustomInfo.IsRubyTop) break;
				stringData.Add(c);
			}
			
			//カラー情報のみコピー
			CharData.CustomCharaInfo rubyInfo = new CharData.CustomCharaInfo();
			rubyInfo.IsColor = original.charData.CustomInfo.IsColor;
			rubyInfo.color = original.charData.CustomInfo.color;
			if (original.charData.CustomInfo.IsEmphasisMark)
			{
				for (int i = 0; i < stringData.Count; ++i)
				{
					CharData data = new CharData(original.charData.CustomInfo.rubyStr[0], rubyInfo);
					rubyList.Add(new UguiNovelTextCharacter(data, rubyFont, rubySize, original.FontStyle ));
				}
			}
			else
			{
				foreach (char c in original.charData.CustomInfo.rubyStr)
				{
					CharData data = new CharData(c, rubyInfo);
					rubyList.Add(new UguiNovelTextCharacter(data, rubyFont, rubySize, original.FontStyle ));
				}
			}
		}
Ejemplo n.º 3
0
		public static pb_GUIStyle Create(
			Color color,
			Color? normalColor = null,
			Color? highlightedColor = null,
			Color? pressedColor = null,
			Color? disabledColor = null,
			Texture2D image = null,
			Sprite sprite = null,
			Font font = null,
					Color? fontColor = null)
		{
			pb_GUIStyle style = ScriptableObject.CreateInstance<pb_GUIStyle>();

			style.color				= color;
			style.image 			= image;
			style.sprite 			= sprite;
			style.font				= font;
			
			if(normalColor != null) 	style.normalColor		= (Color) normalColor;
			if(highlightedColor != null) style.highlightedColor	= (Color) highlightedColor;
			if(pressedColor != null) 	style.pressedColor		= (Color) pressedColor;
			if(disabledColor != null) 	style.disabledColor 		= (Color) disabledColor;
			if(fontColor != null) 		style.fontColor 			= (Color) fontColor;

			return style;
		}
Ejemplo n.º 4
0
 public static int constructor(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         UnityEngine.Font o;
         if(argc==1){
             o=new UnityEngine.Font();
             pushValue(l,true);
             pushValue(l,o);
             return 2;
         }
         else if(argc==2){
             System.String a1;
             checkType(l,2,out a1);
             o=new UnityEngine.Font(a1);
             pushValue(l,true);
             pushValue(l,o);
             return 2;
         }
         return error(l,"New object failed.");
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
Ejemplo n.º 5
0
        void Awake()
        {
            bgTexture = Resources.Load<Texture2D>(Constants.THEME_PATH + Constants.ACTIVE_THEME + "/info_bg");
            font = Resources.Load<Font>("Fonts/" + "Chalkboard");

            DefaultColor();
        }
		public static void SetCharacterInfoToVertex(UIVertex[] verts, UguiNovelTextCharacter character, Font font )
		{

			float minX,maxX,minY,maxY;
			Vector2 uvBottomLeft,uvBottomRight,uvTopRight,uvTopLeft;
			float offsetY;
#if UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6
			//Y座標はフォントアセットのサイズと、文字のサイズを使ってこんな式で計算できる。
			//理屈はわからん!
			offsetY = font.fontSize + 0.1f*(character.FontSize-font.fontSize);

			//positionの設定
			minX = character.charInfo.vert.xMin;
			maxX = character.charInfo.vert.xMax;

			minY = character.charInfo.vert.yMin;
			maxY = character.charInfo.vert.yMax;

			Rect uv = character.charInfo.uv;
			//Flipp処理
			if (character.charInfo.flipped)
			{
				uvBottomLeft = new Vector2(uv.xMax, uv.yMin);
				uvBottomRight = new Vector2(uv.xMax, uv.yMax);
				uvTopLeft = new Vector2(uv.xMin, uv.yMin);
				uvTopRight = new Vector2(uv.xMin, uv.yMax);
			}
			else
			{
				uvBottomLeft = new Vector2(uv.xMin, uv.yMax);
				uvBottomRight = new Vector2(uv.xMax, uv.yMax);
				uvTopLeft = new Vector2(uv.xMin, uv.yMin);
				uvTopRight = new Vector2(uv.xMax, uv.yMin);
			}
#else
			offsetY = 0.1f * (character.FontSize);

			//座標の設定
			minX = character.charInfo.minX;
			maxX = character.charInfo.maxX;
			minY = character.charInfo.minY;
			maxY = character.charInfo.maxY;

			uvBottomLeft = character.charInfo.uvBottomLeft;
			uvBottomRight = character.charInfo.uvBottomRight;
			uvTopRight = character.charInfo.uvTopRight;
			uvTopLeft = character.charInfo.uvTopLeft;
#endif
			//座標の設定
			verts[0].position.x = verts[3].position.x = minX + character.PositionX;
			verts[1].position.x = verts[2].position.x = maxX + character.PositionX;
			verts[0].position.y = verts[1].position.y = minY + character.PositionY + offsetY;
			verts[2].position.y = verts[3].position.y = maxY + character.PositionY + offsetY;

			verts[0].uv0 = uvBottomLeft;
			verts[1].uv0 = uvBottomRight;
			verts[2].uv0 = uvTopRight;
			verts[3].uv0 = uvTopLeft;
		}
Ejemplo n.º 7
0
 void OnEnable()
 {
     //Load initila variables
     SetColors(GetColorDefault(GamestrapHelper.ColorRGBInt(141, 39, 137)));
     font = (Font)AssetDatabase.LoadAssetAtPath(GamestrapHelper.gamestrapRoute + "Fonts/Lato/Lato-Regular.ttf", typeof(Font));
     SetUpColors();
     sceneColors = new List<Color>();
 }
        /// <summary>
        /// Fill label mesh.
        /// </summary>
        /// <param name="mesh">Mesh.</param>
        /// <param name="width">Label width.</param>
        /// <param name="height">Label height.</param>
        /// <param name="text">Label text.</param>
        /// <param name="color">Color.</param>
        /// <param name="align">Text align.</param>
        /// <param name="font">Font.</param>
        /// <param name="fontSize">Font size.</param>
        /// <param name="lineHgt">Line height multiplier.</param>
        /// <param name="effect">Effect.</param>
        /// <param name="effectValue">Effect value.</param>
        /// <param name="effectColor">Effect color.</param>
        public static void FillText(
            Mesh mesh, int width, int height, string text, Color color, TextAnchor align, Font font, int fontSize,
            float lineHgt, GuiFontEffect effect = GuiFontEffect.None, Vector2? effectValue = null, Color? effectColor = null)
        {
            if (mesh == null) {
                return;
            }
            mesh.Clear ();
            if (font == null || string.IsNullOrEmpty (text)) {
                return;
            }

            _settings.fontSize = (int) (fontSize * GuiSystem.Instance.VirtualToRealScaleFactor);
            _settings.resizeTextMaxSize = _settings.fontSize;

            var scale = fontSize / (float) _settings.fontSize;

            _settings.font = font;
            _settings.textAnchor = align;
            _settings.generationExtents = new Vector2 (width, height) / scale;
            _settings.lineSpacing = lineHgt;
            _settings.color = color;
            _generator.Invalidate ();
            if (!_generator.Populate (text, _settings)) {
                return;
            }

            _generator.GetVertices (_verts);

            GuiMeshTools.PrepareBuffer (effect, effectValue, effectColor);

            for (int i = 0, iMax = _verts.Count - 4, charID = 0; i < iMax; charID++) {
                if (text[charID] == ' ') {
                    i += 4;
                    continue;
                }
                _uiV = _verts[i++];
                _c = _uiV.color;
                _v0 = _uiV.position * scale;
                _uv0 = _uiV.uv0;

                _uiV = _verts[i++];
                _v1 = _uiV.position * scale;
                _uv1 = _uiV.uv0;

                _uiV = _verts[i++];
                _v2 = _uiV.position * scale;
                _uv2 = _uiV.uv0;

                _uiV = _verts[i++];
                _v3 = _uiV.position * scale;
                _uv3 = _uiV.uv0;
                GuiMeshTools.FillBuffer (ref _v0, ref _v1, ref _v2, ref _v3, ref _uv0, ref _uv1, ref _uv2, ref _uv3, ref _c);
            }

            GuiMeshTools.GetBuffers (mesh, false);
            mesh.bounds = new Bounds (Vector3.zero, new Vector3 (width, height, 0f));
        }
Ejemplo n.º 9
0
 private static void RebuildForFont(Font f)
 {
   List<Text> list;
   FontUpdateTracker.m_Tracked.TryGetValue(f, out list);
   if (list == null)
     return;
   for (int index = 0; index < list.Count; ++index)
     list[index].FontTextureChanged();
 }
Ejemplo n.º 10
0
 public override void Clear()
 {
     base.Clear();
     m_Text = string.Empty;
     m_FontSize = 100;
     m_Font = null;
     m_Color = Color.white;
     m_FontTexture = null;
 }
Ejemplo n.º 11
0
        public VectorImageData(Glyph glyph, Font font)
        {
            m_Glyph = glyph;
            if (!m_Glyph.unicode.StartsWith(@"\u"))
            {
                m_Glyph.unicode = @"\u" + m_Glyph.unicode;
            }

            m_Font = font;
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="Common.App.ResourceTypes.TextStyle"/> class.
        /// </summary>
        public TextStyle()
        {
            DebugEx.Verbose("Created TextStyle object");

            mFont        = null;
            mFontStyle   = FontStyle.Normal;
            mFontSize    = 12;
            mLineSpacing = 1f;
            mAlignment   = TextAnchor.UpperLeft;
            mColor       = new Color(0f, 0f, 0f);
        }
Ejemplo n.º 13
0
        private static void RebuildForFont(Font f)
        {
            List<Text> texts;
            m_Tracked.TryGetValue(f, out texts);

            if (texts == null)
                return;

            for (var i = 0; i < texts.Count; i++)
                texts[i].FontTextureChanged();
        }
Ejemplo n.º 14
0
 public CodeView(CodeEditorWindow owner, ITextView textView)
 {
     m_Owner = owner;
     _textView = textView;
     _document = _textView.Document;
     var textFont = _textView.Appearance.Text.font;
     _font = textFont ? textFont : GUI.skin.font;
     _navigator = new DefaultTextStructureNavigator();
     Caret.Moved += EnsureCursorIsVisible;
     _textView.DoubleClicked = DoubleClickedDocument;
 }
Ejemplo n.º 15
0
		static MaterialIconHelper()
		{
			if (m_Font == null)
			{
				m_Font = VectorImageManager.GetIconFont(VectorImageManager.materialDesignIconsFontName);
			}
			
			if (m_IconSet == null)
			{
				m_IconSet = VectorImageManager.GetIconSet(VectorImageManager.materialDesignIconsFontName);
			}
		}
Ejemplo n.º 16
0
 static public int get_characterInfo(IntPtr l)
 {
     try {
         UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.characterInfo);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 17
0
 private static void InvokeTextureRebuilt_Internal(Font font)
 {
     Action<Font> textureRebuilt = Font.textureRebuilt;
     if (textureRebuilt != null)
     {
         textureRebuilt(font);
     }
     if (font.m_FontTextureRebuildCallback != null)
     {
         font.m_FontTextureRebuildCallback();
     }
 }
Ejemplo n.º 18
0
 internal void InternalOnAfterDeserialize()
 {
     this.m_FontInternal = this.GetFontInternal();
     this.m_Normal = new GUIStyleState(this, this.GetStyleStatePtr(0));
     this.m_Hover = new GUIStyleState(this, this.GetStyleStatePtr(1));
     this.m_Active = new GUIStyleState(this, this.GetStyleStatePtr(2));
     this.m_Focused = new GUIStyleState(this, this.GetStyleStatePtr(3));
     this.m_OnNormal = new GUIStyleState(this, this.GetStyleStatePtr(4));
     this.m_OnHover = new GUIStyleState(this, this.GetStyleStatePtr(5));
     this.m_OnActive = new GUIStyleState(this, this.GetStyleStatePtr(6));
     this.m_OnFocused = new GUIStyleState(this, this.GetStyleStatePtr(7));
 }
Ejemplo n.º 19
0
 private static void RebuildForFont(Font f)
 {
     List<Text> list;
     m_Tracked.TryGetValue(f, out list);
     if (list != null)
     {
         for (int i = 0; i < list.Count; i++)
         {
             list[i].FontTextureChanged();
         }
     }
 }
Ejemplo n.º 20
0
 internal void InternalOnAfterDeserialize()
 {
     this.m_FontInternal = this.GetFontInternalDuringLoadingThread();
     this.m_Normal = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(0));
     this.m_Hover = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(1));
     this.m_Active = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(2));
     this.m_Focused = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(3));
     this.m_OnNormal = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(4));
     this.m_OnHover = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(5));
     this.m_OnActive = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(6));
     this.m_OnFocused = GUIStyleState.ProduceGUIStyleStateFromDeserialization(this, this.GetStyleStatePtr(7));
 }
Ejemplo n.º 21
0
 static public int get_lineHeight(IntPtr l)
 {
     try {
         UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.lineHeight);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 22
0
 static public int ctor_s(IntPtr l)
 {
     try {
         UnityEngine.Font o;
         o = new UnityEngine.Font();
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 23
0
 static int set_dynamicFont(IntPtr L)
 {
     try
     {
         UnityEngine.Font arg0 = (UnityEngine.Font)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Font));
         NGUIText.dynamicFont = arg0;
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
		public CodeView(EditorWindow owner, ITextView textView)
		{
			m_Owner = owner;
			_textView = textView;
			_document = _textView.Document;
			var textFont = _textView.Appearance.Text.font;
			_font = textFont ? textFont : GUI.skin.font;
			_navigator = new DefaultTextStructureNavigator();
			_completion = new CodeViewCompletion(this, _textView);

			Caret.Moved += OnCaretMoved;
			_textView.Clicked = OnTextViewClicked;
		}
Ejemplo n.º 25
0
        public static void DoImportBitmapFont(string fntPatn)
        {
            if (!IsFnt(fntPatn)) return;

            TextAsset fnt = AssetDatabase.LoadMainAssetAtPath(fntPatn) as TextAsset;
            string text = fnt.text;
            FntParse parse = FntParse.GetFntParse(ref text);
            if (parse == null) return;

            string fntName = Path.GetFileNameWithoutExtension(fntPatn);
            string rootPath = Path.GetDirectoryName(fntPatn);
            string fontPath = string.Format("{0}/{1}.fontsettings", rootPath, fntName);
            string texPath = string.Format("{0}/{1}", rootPath, parse.textureName);

            Font font = AssetDatabase.LoadMainAssetAtPath(fontPath) as Font;
            if (font == null)
            {
                font = new Font();
                AssetDatabase.CreateAsset(font, fontPath);
                font.material = new Material(Shader.Find("UI/Default"));
                font.material.name = "Font Material";
                AssetDatabase.AddObjectToAsset(font.material, font);
            }

            SerializedObject so = new SerializedObject(font);
            so.Update();
            so.FindProperty("m_FontSize").floatValue = parse.fontSize;
            so.FindProperty("m_LineSpacing").floatValue = parse.lineHeight;
            UpdateKernings(so, parse.kernings);
            so.ApplyModifiedProperties();
            so.SetIsDifferentCacheDirty();

            Texture2D texture = AssetDatabase.LoadMainAssetAtPath(texPath) as Texture2D;
            if (texture == null)
            {
                Debug.LogErrorFormat(fnt, "{0}: not found '{1}'.", typeof(BFImporter), texPath);
                return;
            }

            TextureImporter texImporter = AssetImporter.GetAtPath(texPath) as TextureImporter;
            texImporter.textureType = TextureImporterType.GUI;
            texImporter.mipmapEnabled = false;
            texImporter.SaveAndReimport();

            font.material.mainTexture = texture;
            font.material.mainTexture.name = "Font Texture";

            font.characterInfo = parse.charInfos;

            AssetDatabase.SaveAssets();
        }
Ejemplo n.º 26
0
 public void createClientFrame(int i, int j)
 {
     myWidth        = Screen.width;
     myHeight       = Screen.height;
     fullGameScreen = new RSImageProducer(myWidth, myHeight);
     helvetica      = new UnityEngine.Font("Helvetica");
     drawLoadingText(0, "Loading...");
     signlink.run();
     Loom.StartSingleThread(() => { startUp(); }, System.Threading.ThreadPriority.Normal, true);
     for (int k1 = 0; k1 < 10; k1++)
     {
         aLongArray7[k1] = NetDrawingTools.CurrentTimeMillis();
     }
 }
Ejemplo n.º 27
0
 static public int HasCharacter(IntPtr l)
 {
     try {
         UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
         System.Char      a1;
         checkType(l, 2, out a1);
         var ret = self.HasCharacter(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
        /// <summary>
        /// Draws a string onto a <see cref="GenericImage{T}"/>.
        /// </summary>
        /// <param name="image">The image where the string will be drawn to.</param>
        /// <param name="font">The font to use when drawing the string.</param>
        /// <param name="text">The string to draw.</param>
        /// <param name="x">The x position where the string will be drawn at.</param>
        /// <param name="y">The y position where the string will be drawn at.</param>
        public static void DrawString(this GenericImage<Color> image, Font font, string text, float x, float y)
        {
            if (image == null)
            {
                throw new ArgumentNullException("image");
            }

            if (font == null)
            {
                throw new ArgumentNullException("font");
            }

            throw new NotImplementedException();
        }
Ejemplo n.º 29
0
 static public int GetCharacterInfo(IntPtr l)
 {
     try{
         if (matchType(l, 2, typeof(System.Char), typeof(UnityEngine.CharacterInfo), typeof(int), typeof(UnityEngine.FontStyle)))
         {
             UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
             System.Char      a1;
             checkType(l, 2, out a1);
             UnityEngine.CharacterInfo a2;
             System.Int32 a3;
             checkType(l, 4, out a3);
             UnityEngine.FontStyle a4;
             checkEnum(l, 5, out a4);
             System.Boolean ret = self.GetCharacterInfo(a1, out a2, a3, a4);
             pushValue(l, ret);
             pushValue(l, a2);
             return(2);
         }
         else if (matchType(l, 2, typeof(System.Char), typeof(UnityEngine.CharacterInfo), typeof(int)))
         {
             UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
             System.Char      a1;
             checkType(l, 2, out a1);
             UnityEngine.CharacterInfo a2;
             System.Int32 a3;
             checkType(l, 4, out a3);
             System.Boolean ret = self.GetCharacterInfo(a1, out a2, a3);
             pushValue(l, ret);
             pushValue(l, a2);
             return(2);
         }
         else if (matchType(l, 2, typeof(System.Char), typeof(UnityEngine.CharacterInfo)))
         {
             UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
             System.Char      a1;
             checkType(l, 2, out a1);
             UnityEngine.CharacterInfo a2;
             System.Boolean            ret = self.GetCharacterInfo(a1, out a2);
             pushValue(l, ret);
             pushValue(l, a2);
             return(2);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 30
0
 static public int set_material(IntPtr l)
 {
     try {
         UnityEngine.Font     self = (UnityEngine.Font)checkSelf(l);
         UnityEngine.Material v;
         checkType(l, 2, out v);
         self.material = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 31
0
 static public int set_fontNames(IntPtr l)
 {
     try {
         UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
         System.String[]  v;
         checkType(l, 2, out v);
         self.fontNames = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 32
0
 static public int set_characterInfo(IntPtr l)
 {
     try {
         UnityEngine.Font            self = (UnityEngine.Font)checkSelf(l);
         UnityEngine.CharacterInfo[] v;
         checkType(l, 2, out v);
         self.characterInfo = v;
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 33
0
 static public int set_characterInfo(IntPtr l)
 {
     try {
         UnityEngine.Font            self = (UnityEngine.Font)checkSelf(l);
         UnityEngine.CharacterInfo[] v;
         checkArray(l, 2, out v);
         self.characterInfo = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 34
0
 static public int RequestCharactersInTexture__String(IntPtr l)
 {
     try {
         UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
         System.String    a1;
         checkType(l, 2, out a1);
         self.RequestCharactersInTexture(a1);
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 35
0
        public static void DrawText(this Texture2D tx, string sText, int offsetX, int offsetY, Font font1, Texture2D font1Tx, int fontSize) {
            CharacterInfo ci;
            char[] cText = sText.ToCharArray();

            //Material fontMat = font1.material;
            //Texture2D fontTx = (Texture2D) fontMat.mainTexture;
            Texture2D fontTx = font1Tx;

            int x, y, w, h;
            int posX = 0;

            font1.GetCharacterInfo('I', out ci);

            //int IHeight = (int) (ci.flipped ? (float) fontTx.width * (ci.uv.width) : (float) fontTx.height * (-ci.uv.height));

            for (int i = 0; i < cText.Length; i++) {
                font1.GetCharacterInfo(cText[i], out ci);

                x = (int)((float)fontTx.width * ci.uv.x);
                y = (int)((float)fontTx.height * (ci.uv.y + ci.uv.height));
                w = (int)((float)fontTx.width * ci.uv.width);
                h = (int)((float)fontTx.height * (-ci.uv.height));

                Color[] charPix = fontTx.GetPixels(x, y, w, h);

                if (ci.flipped) {
                    charPix = Colors_FlipRight(charPix, w, h);

                    x = posX;
                    //y = (IHeight - w) + w/2;
                    y = (int)-ci.vert.y;

                    int tmp = w;
                    w = h;
                    h = tmp;
                }
                else {
                    x = posX + (int)ci.vert.x;
                    y = (int)-ci.vert.y;
                }

                Color[] basePix = tx.GetPixels(offsetX + x, offsetY + y, w, h);
                Colors_Composite(ref basePix, charPix, w, h);


                tx.SetPixels(offsetX + x, offsetY + y, w, h, basePix);

                posX += (int)ci.width;
            }
        }
Ejemplo n.º 36
0
 static public int set_material(IntPtr l)
 {
     try {
         UnityEngine.Font     self = (UnityEngine.Font)checkSelf(l);
         UnityEngine.Material v;
         checkType(l, 2, out v);
         self.material = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 37
0
 static public int set_fontNames(IntPtr l)
 {
     try {
         UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
         System.String[]  v;
         checkArray(l, 2, out v);
         self.fontNames = v;
         pushValue(l, true);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 38
0
        public override void OnEnter()
        {
            GameObject _go = Fsm.GetOwnerDefaultTarget(gameObject);

            if (_go != null)
            {
                _text = _go.GetComponent <UnityEngine.UI.Text>();
                if (resetOnExit.Value)
                {
                    _originalFont = _text.font;
                }
                _text.font = font.Value as Font;
            }
        }
    static int GetCharacterInfo(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 3)
            {
                UnityEngine.Font          obj  = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
                char                      arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.CharacterInfo arg1;
                bool                      o = obj.GetCharacterInfo(arg0, out arg1);
                LuaDLL.lua_pushboolean(L, o);
                ToLua.PushValue(L, arg1);
                return(2);
            }
            else if (count == 4)
            {
                UnityEngine.Font          obj  = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
                char                      arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.CharacterInfo arg1;
                int  arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
                bool o    = obj.GetCharacterInfo(arg0, out arg1, arg2);
                LuaDLL.lua_pushboolean(L, o);
                ToLua.PushValue(L, arg1);
                return(2);
            }
            else if (count == 5)
            {
                UnityEngine.Font          obj  = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
                char                      arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
                UnityEngine.CharacterInfo arg1;
                int arg2 = (int)LuaDLL.luaL_checknumber(L, 4);
                UnityEngine.FontStyle arg3 = (UnityEngine.FontStyle)ToLua.CheckObject(L, 5, typeof(UnityEngine.FontStyle));
                bool o = obj.GetCharacterInfo(arg0, out arg1, arg2, arg3);
                LuaDLL.lua_pushboolean(L, o);
                ToLua.PushValue(L, arg1);
                return(2);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Font.GetCharacterInfo"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Ejemplo n.º 40
0
 static public int GetCharacterInfo(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (argc == 3)
         {
             UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
             System.Char      a1;
             checkType(l, 2, out a1);
             UnityEngine.CharacterInfo a2;
             var ret = self.GetCharacterInfo(a1, out a2);
             pushValue(l, ret);
             pushValue(l, a2);
             return(2);
         }
         else if (argc == 4)
         {
             UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
             System.Char      a1;
             checkType(l, 2, out a1);
             UnityEngine.CharacterInfo a2;
             System.Int32 a3;
             checkType(l, 4, out a3);
             var ret = self.GetCharacterInfo(a1, out a2, a3);
             pushValue(l, ret);
             pushValue(l, a2);
             return(2);
         }
         else if (argc == 5)
         {
             UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
             System.Char      a1;
             checkType(l, 2, out a1);
             UnityEngine.CharacterInfo a2;
             System.Int32 a3;
             checkType(l, 4, out a3);
             UnityEngine.FontStyle a4;
             checkEnum(l, 5, out a4);
             var ret = self.GetCharacterInfo(a1, out a2, a3, a4);
             pushValue(l, ret);
             pushValue(l, a2);
             return(2);
         }
         return(error(l, "No matched override function to call"));
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 41
0
 static public int HasCharacter(IntPtr l)
 {
     try{
         UnityEngine.Font self = (UnityEngine.Font)checkSelf(l);
         System.Char      a1;
         checkType(l, 2, out a1);
         System.Boolean ret = self.HasCharacter(a1);
         pushValue(l, ret);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Ejemplo n.º 42
0
 static public int ctor__String_s(IntPtr l)
 {
     try {
         UnityEngine.Font o;
         System.String    a1;
         checkType(l, 1, out a1);
         o = new UnityEngine.Font(a1);
         pushValue(l, true);
         pushValue(l, o);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Ejemplo n.º 43
0
 static void TextMesh_font(JSVCall vc)
 {
     if (vc.bGet)
     {
         UnityEngine.TextMesh _this = (UnityEngine.TextMesh)vc.csObj;
         var result = _this.font;
         JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
     }
     else
     {
         UnityEngine.Font     arg0  = (UnityEngine.Font)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
         UnityEngine.TextMesh _this = (UnityEngine.TextMesh)vc.csObj;
         _this.font = arg0;
     }
 }
 static int SetFont(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.GameObject arg0 = (UnityEngine.GameObject)ToLua.CheckObject(L, 1, typeof(UnityEngine.GameObject));
         UnityEngine.Font       arg1 = (UnityEngine.Font)ToLua.CheckObject(L, 2, typeof(UnityEngine.Font));
         GameFramework.UtilityUnity.SetFont(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
    static int QPYX_set_font_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.UI.Text QPYX_obj_YXQP = (UnityEngine.UI.Text)QPYX_o_YXQP;
            UnityEngine.Font QPYX_arg0_YXQP = (UnityEngine.Font)ToLua.CheckObject(L_YXQP, 2, typeof(UnityEngine.Font));
            QPYX_obj_YXQP.font = QPYX_arg0_YXQP;
            return(0);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index font on a nil value"));
        }
    }
    static int QPYX_get_font_YXQP(IntPtr L_YXQP)
    {
        object QPYX_o_YXQP = null;

        try
        {
            QPYX_o_YXQP = ToLua.ToObject(L_YXQP, 1);                        UnityEngine.UI.Text QPYX_obj_YXQP = (UnityEngine.UI.Text)QPYX_o_YXQP;
            UnityEngine.Font QPYX_ret_YXQP = QPYX_obj_YXQP.font;
            ToLua.PushSealed(L_YXQP, QPYX_ret_YXQP);
            return(1);
        }
        catch (Exception QPYX_e_YXQP)            {
            return(LuaDLL.toluaL_exception(L_YXQP, QPYX_e_YXQP, QPYX_o_YXQP, "attempt to index font on a nil value"));
        }
    }
Ejemplo n.º 47
0
// fields

// properties
    static void Font_material(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.Font _this = (UnityEngine.Font)vc.csObj;
            var result             = _this.material;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Material arg0  = (UnityEngine.Material)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.Font     _this = (UnityEngine.Font)vc.csObj;
            _this.material = arg0;
        }
    }
Ejemplo n.º 48
0
 public static int set_font_wrap(long L)
 {
     try
     {
         long             nThisPtr = FCLibHelper.fc_get_inport_obj_ptr(L);
         Text             ret      = get_obj(nThisPtr);
         UnityEngine.Font arg0     = FCGetObj.GetObj <UnityEngine.Font>(FCLibHelper.fc_get_intptr(L, 0));
         ret.font = arg0;
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Ejemplo n.º 49
0
// fields
    static void TextGenerationSettings_font(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
            var result = _this.font;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.Font arg0 = (UnityEngine.Font)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.TextGenerationSettings _this = (UnityEngine.TextGenerationSettings)vc.csObj;
            _this.font = arg0;
            JSMgr.changeJSObj(vc.jsObjID, _this);
        }
    }
 static int HasCharacter(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         UnityEngine.Font obj  = (UnityEngine.Font)ToLua.CheckObject(L, 1, typeof(UnityEngine.Font));
         char             arg0 = (char)LuaDLL.luaL_checknumber(L, 2);
         bool             o    = obj.HasCharacter(arg0);
         LuaDLL.lua_pushboolean(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 51
0
 public TextButton(Rect r, Texture down, Texture up, Texture disableDown, Texture disableUp, DelegateButton delega, Font font, bool bKeepSt = true, int shadowDist = 1)
     : base(r,down,up,disableDown,disableUp, delega, bKeepSt, shadowDist)
 {
     mStyle = new GUIStyle();
     mStyle.font = font;
     mStyle.clipping = TextClipping.Clip;
     mStyle.wordWrap = true;
     mStyle.fontSize = 10;
     mStyle.alignment = TextAnchor.MiddleCenter;
     mStyle.fontStyle = FontStyle.Normal;
     mStyle.normal.textColor = Color.black;
     mTextColor = Color.black;
     mTextOffset = Vector2.zero;
     mText = "";
     mTextOffsetSpaces = 0;
 }
Ejemplo n.º 52
0
 static int SetFont(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 3);
         TextEx           obj  = (TextEx)ToLua.CheckObject <TextEx>(L, 1);
         UnityEngine.Font arg0 = (UnityEngine.Font)ToLua.CheckObject(L, 2, typeof(UnityEngine.Font));
         string           arg1 = ToLua.CheckString(L, 3);
         obj.SetFont(arg0, arg1);
         return(0);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Ejemplo n.º 53
0
        public static GameObject MakeTextColorButton2(
			string name, Vector2 size, Vector2 position, 
			string buttontext, Font font, int fontsize, Color color, Color buttonColor, TextAnchor alignment,
			Action<string> callback)
        {
            //make the button game object
            GameObject btnGO = new GameObject(name);
            btnGO.name = name;

            //xform
            RectTransform brect = btnGO.AddComponent<RectTransform>();
            RectTransformExtensions.SetSize(brect,size);
            RectTransformExtensions.SetLeftTopPosition(brect,position);

            //button.image.color = Color.red;
            //add image
            Image img = btnGO.AddComponent<Image> ();
            img.color = buttonColor;

            //make the button
            Button button = btnGO.AddComponent<Button>();
            button.onClick.AddListener(() => { callback(name); });

            //button color
            ColorBlock cb = button.colors;
            cb.normalColor = new Color (0.5f, 0.5f, 0.5f, 0.5f);
            cb.disabledColor = new Color (0.5f, 0.5f, 0.5f, 0.5f);
            cb.highlightedColor = new Color (0.9f, 0.9f, 0.9f, 0.5f);

            //make the button text
            GameObject txtGO = new GameObject("text"+name);
            txtGO.name = "text"+name;
            txtGO.transform.SetParent(btnGO.transform, false);

            RectTransform tbrect = txtGO.AddComponent<RectTransform>();
            RectTransformExtensions.SetSize(tbrect,size);

            txtGO.AddComponent<Text>();
            Text tval = txtGO.GetComponent<Text>();
            tval.alignment = alignment;
            tval.text = buttontext;
            tval.font = font;
            tval.color = color;
            tval.fontSize = fontsize;

            return btnGO;
        }
    static int set_font(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.Text obj  = (UnityEngine.UI.Text)o;
            UnityEngine.Font    arg0 = (UnityEngine.Font)ToLua.CheckUnityObject(L, 2, typeof(UnityEngine.Font));
            obj.font = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index font on a nil value" : e.Message));
        }
    }
    static int get_font(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.UI.Text obj = (UnityEngine.UI.Text)o;
            UnityEngine.Font    ret = obj.font;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index font on a nil value" : e.Message));
        }
    }
Ejemplo n.º 56
0
 public InputText(Rect r, Texture down, Texture up, Texture disableDown, Texture disableUp, DelegateButton delega, Font font, Texture Indicator, string emptyText, bool bKeepSt = false, int shadowDist = 1)
     : base(r,down,up,disableDown,disableUp, delega, font, bKeepSt, shadowDist)
 {
     mSelected = false;
     mDrawIndicator = false;
     mIndicatorTexture = (Texture2D)Indicator;
     mIndicatorRect = new Rect(0, 0, 2, 0);
     UpdateIndicatorSize();
     UpdateIndicatorPos();
     mEmptyText = emptyText;
     mMaxLength = -1;
     mStyle.wordWrap = false;
     mIndicatorPos = 0;
     //#if UNITY_IPHONE || UNITY_ANDROID
     mOldInput = "";
     //#endif
 }
Ejemplo n.º 57
0
		public override void Reset()
		{
			skin = null;
			style = null;
			font = null;
			minBubbleSize = new Vector2(64f, 64f);
			bubbleOffset = 0f;
			bubbleOffsetVector = Vector2.zero;
			placement = PlacementEnum.Center;
			color = Color.white;
			fadeIn = 0.3f;
			fadeOut = 0.3f;
			volume = 1f;
			audioDelay = 0f;
			guiDepth = 0;
			debug = false;
			audioVolume = null;
			audioVolumeMultiply = false;
			audioPitch = 1f;
		}
Ejemplo n.º 58
0
        public void Awake()
        {
            this.camera = FindObjectOfType<CameraController>();
            this.eventSystem = FindObjectOfType<EventSystem>();
            this.font = (font == null) ? Resources.GetBuiltinResource<Font>("Arial.ttf") : font;
            this.labels = GetComponentsInChildren<Text>();
            this.menus = GetComponentsInChildren<Canvas>().Select(c => c.gameObject).ToArray();

            GetComponentsInChildren<Selectable>().ToList().ForEach(s => s.colors = colors);

            foreach (Text label in labels)
            {
                label.font = font;
                label.text = label.text.Localize();
            }

            if (eventSystem == null)
            {
                eventSystem = new GameObject("Event System", typeof(EventSystem)).GetComponent<EventSystem>();
            }
        }
Ejemplo n.º 59
0
        virtual protected void LoadFont()
        {
            _font = (Font)Resources.Load(name, typeof(Font));
            if (_font == null)
                _font = (Font)Resources.Load("Fonts/" + name, typeof(Font));
            if (_font == null)
                _font = (Font)Resources.GetBuiltinResource(typeof(Font), "Arial.ttf");
            if (_font == null)
            {
                if (name != UIConfig.defaultFont)
                {
                    DynamicFont bf = FontManager.GetFont(UIConfig.defaultFont) as DynamicFont;
                    if (bf != null)
                        _font = bf._font;
                }
                if (_font == null)
                    throw new Exception("Cant load font '" + name + "'");
            }

            _font.textureRebuildCallback += textureRebuildCallback;
            this.mainTexture = new NTexture(_font.material.mainTexture);
        }
Ejemplo n.º 60
0
        public void init(Font font, Material material)
        {
            info_ = new CharacterInfo[CHAR_SIZE];
            for (var i = 0; i < info_.Length; ++i) {
            char ch = (char)(i+CHAR_START);
            font.GetCharacterInfo(ch, out info_[i]);
            }
            info8_ = info_[(int)'8'-CHAR_START];
            put_string_work_ = new char[128];

            vertices_ = new Vector3[2][] { new Vector3[FONT_CHAR_MAX*4], new Vector3[FONT_CHAR_MAX*4], };
            uvs_ = new Vector2[2][] { new Vector2[FONT_CHAR_MAX*4], new Vector2[FONT_CHAR_MAX*4], };
            var triangles = new int[FONT_CHAR_MAX*6];
            for (var i = 0; i < FONT_CHAR_MAX; ++i) {
            triangles[i*6+0] = i*4+0;
            triangles[i*6+1] = i*4+1;
            triangles[i*6+2] = i*4+2;
            triangles[i*6+3] = i*4+2;
            triangles[i*6+4] = i*4+1;
            triangles[i*6+5] = i*4+3;
            }
            mesh_ = new Mesh();
            mesh_.name = "font";
            mesh_.MarkDynamic();
            mesh_.vertices = vertices_[0];
            mesh_.uv = uvs_[0];
            mesh_.triangles = triangles;
            mesh_.bounds = new Bounds(Vector3.zero, Vector3.one * 99999999);
            material_ = material;
            material_.SetColor("_Colors0", new Color(0f, 0f, 0f)); // None
            material_.SetColor("_Colors1", new Color(1f, 0.4f, 0.4f)); // Red
            material_.SetColor("_Colors2", new Color(0.4f, 0.4f, 1f)); // Blue
            material_.SetColor("_Colors3", new Color(1f, 0.4f, 1f)); // Magenta
            material_.SetColor("_Colors4", new Color(0.4f, 1f, 0.4f)); // Green
            material_.SetColor("_Colors5", new Color(1f, 1f, 0.4f)); // Yellow
            material_.SetColor("_Colors6", new Color(0.4f, 1f, 1f)); // Cyan
            material_.SetColor("_Colors7", new Color(1f, 1f, 1f)); // White
        }