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
1
Question by sdgd · Feb 08, 2013 at 05:29 PM · c#sizemax

how to change Texture Max Size with scripting

followed a bit this and cant seem to find how do I change Max Size

it can be found in inspector

Max Size

 using UnityEngine;
 using System.Collections;
 
 public class GuiFloat : MonoBehaviour {
     public Texture2D Leaves;
     
     
     void Update(){
         Leaves.texelSize = (new Vector2(32,32));
     }
 }
 

I'm almost sure .texelSize isn't right one for that

but how do I change that value by scripting?

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
4
Best Answer

Answer by DaveA · Feb 08, 2013 at 05:56 PM

http://docs.unity3d.com/Documentation/ScriptReference/TextureImporter-maxTextureSize.html

then (untested)

     string imgAssetPath = AssetDatabase.GetAssetPath(Leaves);
     TextureImporter ti = new TextureImporter();
     TextureImporterSettings tis = new TextureImporterSettings();
     ti.ReadTextureSettings (tis);
     ti.maxTextureSize = 32;
     ti.SetTextureSettings (tis);
     AssetDatabase.WriteImportSettingsIfDirty (imgAssetPath);
     AssetDatabase.ImportAsset(imgAssetPath, ImportAssetOptions.ForceUpdate);
 
Comment
Add comment · Show 3 · 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 DaveA · Feb 08, 2013 at 05:57 PM 0
Share

Some of that may not be needed, I just lifted this from some old code that worked for me.

avatar image sdgd · Feb 08, 2013 at 07:43 PM 1
Share

gr8 thanks Yoda with your code I figured partionally where should I look

as with your code I got just too many errors I couldn't fix

I came across Editor class "Texture Importer" + Apply import settings question and I still couldn't figure out how to get path and than I came across Getting the absolute path of current project and I tried it and it works perfectly

this is the code I'm using now:

 TextureImporter tImporter = AssetImporter.GetAtPath("Assets/Textures/Floor/Leaves/Leaves.jpg") as TextureImporter;
 tImporter.mipmapEnabled = true;
 tImporter.isReadable = true;
 tImporter.maxTextureSize = 32;
 AssetDatabase.ImportAsset( "Assets/Textures/Floor/Leaves/Leaves.jpg", ImportAssetOptions.ForceUpdate );


tho I think for 2 months old programmer <--- me I'm pretty good

thanks Yoda may the force be with you

avatar image sdgd · Feb 08, 2013 at 08:00 PM 0
Share

it's strange tho this path works for me searching sub folders

while path for sub folders didn't for resources.load

Resources.Load ("Category1/Hatchet") as GameObject as provided here as sub answer

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

11 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

Related Questions

Maximum scene size? 2 Answers

NGUI resizes fine in engine but not on actual devices 1 Answer

How do you set minimum EditorWindow size when undocked? 0 Answers

Why is it working in JS but not C# 1 Answer

Big size after export from Xcode 1 Answer


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