• 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 /
avatar image
0
Question by suzit-punk · Jul 31, 2015 at 09:38 AM · texturetextureingchar

Char To Texture

I have one major issue in applying texture on object with respect to char. For e.g.: I have array of char[] which has like "R" "E" "D" of string "RED". so, with respect to this i want to apply these texture on single object each like on quad. Quad 1 has "R" of char[0] texture Quad 2 - "E" of char[1] and Quad - "D" char[2].

Comment
Add comment · Show 2
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 Graham-Dunnett ♦♦ · Jul 31, 2015 at 09:39 AM 0
Share

I have no idea what your question is asking.

avatar image suzit-punk · Jul 31, 2015 at 12:13 PM 0
Share

@ Graham appreciate your concern, but i got the complete solution below.

1 Reply

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

Answer by shriya · Jul 31, 2015 at 11:06 AM

HI Suzit,

If I have understood correctly then the solution is mentioned below. Keep your Textures in Resources Folder and name your texture as per alphabet it contains (see attachment). This script is basically instantiating cubes equal to the length of your character array and applying texture to it..Output is also shown! For any clarification feel free to ask . Hope it helps.

 using UnityEngine;
 using System.Collections;
 
 public class ApplyTexture : MonoBehaviour {
     private char[] charac={'R','E','D'};
     public GameObject cube;
     // Use this for initialization
     void Start () 
     {
         for (int i = 0; i<charac.Length; i++) 
         {
             GameObject x = Instantiate(cube,new Vector3(i*2,0,0),Quaternion.identity) as GameObject;
             Texture gettexture =  Resources.Load (charac[i].ToString()) as Texture;
             x.GetComponent<Renderer>().material.mainTexture =gettexture;
 
         }
     }
     
 
 }
 


[1]: /storage/temp/51333-screen-shot-2015-07-31-at-42736-pm.png

[2]: /storage/temp/51334-screen-shot-2015-07-31-at-42955-pm.png


screen-shot-2015-07-31-at-42736-pm.png (12.8 kB)
screen-shot-2015-07-31-at-42955-pm.png (17.4 kB)
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 suzit-punk · Jul 31, 2015 at 12:13 PM 0
Share

Damnnnn!!you shriya got the solution thanks a lot.

avatar image shriya · Jul 31, 2015 at 12:21 PM 0
Share

Happy to help :)

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

3 People are following this question.

avatar image avatar image avatar image

Related Questions

Assigning UV Map to model at runtime 0 Answers

Texture blending 0 Answers

Gray line at top of the texture 0 Answers

Removing mipmap levels? 0 Answers

swapping face textures for expressions? 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges