Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 /
avatar image
0
Question by yashesh · Apr 10, 2014 at 07:36 AM · texturecolorruntime

How to change the color of predefine portion of the texture?

Hello Everyone, I want to change the color of the predefine portion of the texture.

See the attached image.

I want to change the color of the portion which are in the Red Rectangle.

can anyone please help me?

Thanks Yaalt textshesh

box.png (299.6 kB)
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

Answer by doska · Apr 10, 2014 at 10:09 AM

You can mark texture as Sprite.multiple, and separate this part as sprite. After that - do everything that you want with it. Sprites can overlap, so, you can have big sprite - whole texture and small one - selected part. Actually, you can separate it dynamicly via TextureImporter.spriteSheet

Comment
Add comment · Show 4 · 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 yashesh · Apr 10, 2014 at 10:32 AM 0
Share

Sounds good.But i don't have idea about Sprite. can you please provide me some example link for reference? Thanks for quick reply :)

avatar image doska · Apr 11, 2014 at 04:12 AM 0
Share

In attachement salt textcreenshot, it's just you to see how it looks loke. Here is a script to work with sprite. Sprite system is new, so there is not much tutorials on it. But sprite it's just a Texture2D in different maner.

 public static void PrepeareTexture2DAsSprite (string pathToTexture, bool isSpriteSingle = true, Sprite$$anonymous$$etaData[] spriteSheetData = null)
     {
     TextureImporter textureImporter = AssetImporter.GetAtPath (pathToTexture) as TextureImporter;
     TextureImporterSettings textureImporterSettings = new TextureImporterSettings ();
     
     textureImporter.textureType = TextureImporterType.Sprite;
     
     textureImporterSettings.spritePixelsToUnits = 1.0f;
     textureImporterSettings.mipmapEnabled = false;
     textureImporterSettings.readable = true;
     textureImporterSettings.maxTextureSize = 4096;
     textureImporterSettings.textureFormat = TextureImporterFormat.ARGB32;
     textureImporterSettings.filter$$anonymous$$ode = Filter$$anonymous$$ode.Point;
     textureImporterSettings.wrap$$anonymous$$ode = TextureWrap$$anonymous$$ode.Clamp;
     textureImporterSettings.npotScale = TextureImporterNPOTScale.None;
     textureImporterSettings.readable = true;
     
     textureImporter.SetTextureSettings (textureImporterSettings);
     
     AssetDatabase.ImportAsset (pathToTexture, ImportAssetOptions.ForceUpdate);
     AssetDatabase.Refresh ();
     
     if (isSpriteSingle)
     textureImporterSettings.sprite$$anonymous$$ode = (int) SpriteImport$$anonymous$$ode.Single;
     else
     {
     textureImporterSettings.sprite$$anonymous$$ode = (int) SpriteImport$$anonymous$$ode.$$anonymous$$ultiple;
     
     if (spriteSheetData != null)
     {
     textureImporter.spritesheet = spriteSheetData;
     }
     }
     
     textureImporter.SetTextureSettings (textureImporterSettings);
     
     AssetDatabase.ImportAsset (pathToTexture, ImportAssetOptions.ForceUpdate);
     AssetDatabase.Refresh ();
     }


01.jpg (106.6 kB)
avatar image yashesh · Apr 11, 2014 at 09:25 AM 0
Share

Thanks a lot for for your valuable response :) but i am getting compile time error "he type or namespace name `Sprite$$anonymous$$etaData' could not be found. Are you missing a using directive or an assembly reference?" can you please help me for that ?

avatar image doska · Apr 11, 2014 at 09:48 AM 0
Share

Sprite$$anonymous$$etaData it's UnityEditor namespace. Script, that i give you, it's Editor script. You can use

 #if UNITY_EDITOR
 ...
 #endif

to disable compiling editor part of script from behavior script.

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

22 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

Related Questions

Reverse of Texture.EncodeToEXR in unity? 0 Answers

Change material color at runtime!! 5 Answers

How to Make a Character Flicker? 1 Answer

GetPixel Returning Inaccurate Color 1 Answer

Would a color based game run better than a texture based game? 2 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