Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Help Room /
avatar image
0
Question by muddu · Apr 21, 2016 at 03:11 PM · fontlanguage

Not able to locate the font downloaded from internet

I downloaded a font for Hindi Language (k010.ttf). I have a menu for the game. In that I have a button (Language Change). On click of that button the fonts of language should change from English to Hindi.

I wrote this script:

using UnityEngine; using System.Collections; using UnityEngine.UI;

public class LangChng : MonoBehaviour {

 //public Font myNewFont;

 public GameObject go1;
 public GameObject go1b1;
 public GameObject go1b2;
 public GameObject go1b3;
 public GameObject go1b4;
 public GameObject go1b5;

 public GameObject go2;
 public GameObject go2b1;
 public GameObject go2b2;
 public GameObject go2b3;
 public GameObject go2b4;

 public GameObject go3;
 public GameObject go3b1;
 public GameObject go3b2;
 public GameObject go3b3;
 public GameObject go3b4;
 public GameObject go3b5;
 public GameObject go3b6;
 public GameObject go3b7;

 public GameObject go4;
 public GameObject go4b1;

 public GameObject go5b1;
 public GameObject go5b2;
 public GameObject go5b3;
 //public Button but;

 // Use this for initialization

 public void onClick ()
 {
     go1.SetActive (true);
     //go1.SetActive (true);
     go1b1.GetComponentInChildren<Text>().text = "Vs CPU...";
     go1b2.GetComponentInChildren<Text>().text = "Vs Player...";
     go1b3.GetComponentInChildren<Text>().text = "High Score...";
     go1b4.GetComponentInChildren<Text>().text = "Options...";
     go1b5.GetComponentInChildren<Text>().text = "Exit...";
     //go1.SetActive(false);
     go1.SetActive(false);

     go2.SetActive (true);
     //go1.SetActive (true);
     go2b1.GetComponentInChildren<Text>().text = "Back...";
     go2b2.GetComponentInChildren<Text>().text = "Slow...";
     go2b3.GetComponentInChildren<Text>().text = "Rock...";
     go2b4.GetComponentInChildren<Text>().text = "Pop...";
     //go1.SetActive(false);
     go2.SetActive(false);

     go3.SetActive (true);
     //go1.SetActive (true);
     go3b1.GetComponentInChildren<Text>().text = "Help...";
     go3b2.GetComponentInChildren<Text>().text = "Credits...";
     go3b3.GetComponentInChildren<Text>().text = "About...";
     go3b4.GetComponentInChildren<Text>().text = "Sound...";
     go3b5.GetComponentInChildren<Text>().text = "Music...";
     go3b6.GetComponentInChildren<Text>().text = "Language...";
     go3b7.GetComponentInChildren<Text>().text = "Back...";
     //go1.SetActive(false);
     go3.SetActive(false);

     go4.SetActive (true);
     //go1.SetActive (true);
     go4b1.GetComponentInChildren<Text>().text = "Back...";
     //go1.SetActive(false);
     go4.SetActive(false);


     go5b1.GetComponentInChildren<Text>().text = "English...";

     go5b2.GetComponentInChildren<Text>().font = Resources.GetBuiltinResource(typeof(Font), "k010.ttf") as Font;
     //go5b2.GetComponent<Text>().font = Resources.GetBuiltinResource<Font>("k010.ttf");
     //go5b2.GetComponent<Text>().font = myNewFont;
     go5b2.GetComponentInChildren<Text>().text = "asd";

     go5b3.GetComponentInChildren<Text>().text = "Back...";
 }

}

I downloaded the font file and put it in the Assets folder. However the code is not running and giving the error:

Failed to find k010.ttf UnityEngine.Resources:GetBuiltinResource(Type, String) LangChng:onClick() (at Assets/Scripts/LangChng.cs:83) UnityEngine.EventSystems.EventSystem:Update()

The resource k010.ttf could not be loaded from the resource file! UnityEngine.Resources:GetBuiltinResource(Type, String) LangChng:onClick() (at Assets/Scripts/LangChng.cs:83) UnityEngine.EventSystems.EventSystem:Update()

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by TBruce · Apr 21, 2016 at 05:09 PM

@muddu

You are calling "Resources.GetBuiltinResource". Two problems here

  1. "k010.ttf" is not a Unity built in resource

  2. You are calling using the "Resources" class, this requires the resource to be located in a folder named "Resource" or a sub-folder of "Resources".

Do the following, if there is not already one there create a folder named "Resources" in the "Assets" folder. Next create a folder named "Fonts" within the "Resources" folder. Now move the "k010.ttf" font into the "Assets/Resources/Fonts" folder. Now add the following code

 public Font hindFont;
 
 void Start ()
 {
     if (hindFont == null)
     {
         hindFont = (Font)Resources.Load("Fonts/k010.ttf", typeof(Font));
     }
 }
 

You can either do the following once in the Start() function (more preferred) or you can do the following in the Update() function

 if (hindFont != null)
 {
     hindFont = (Font)Resources.Load("Fonts/k010.ttf", typeof(Font));
     go5b2.GetComponentInChildren<Text>().font = hindFont;
 }
Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image muddu · Apr 22, 2016 at 04:11 AM 0
Share

Thanks for the effort but the problem isn't solved ! The error message is now replaced by a warning and I am still not able to get the desired font change. The warning is:

Font size and style overrides are only supported for dynamic fonts. UnityEditor.DockArea:OnGUI()

avatar image muddu · Apr 22, 2016 at 08:40 PM 0
Share

Thank You, The problem is now solved

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

56 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Thai language issue - Font shrinks 0 Answers

TextMeshpro arabic fonts stop displaying more than one word(last one) 1 Answer

Easy ways for Multilingual Games 1 Answer

No readable font with unity 5.3.0 on OSX 10.9.5 6 Answers

Making a translatable custom font 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges