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 /
This post has been wikified, any user with enough reputation can edit it.
avatar image
0
Question by badweasel · Mar 02, 2015 at 05:39 AM · iostexturematerial

How to force a texture to be included in an iOS Project?

First time building and running my Unity3D app on my iPhone and it appears that all the textures are missing. Everything is just a solid block of whatever color I made it. When running in Unity I see everything correctly. See images...

missing textures in iOS

I am using custom shaders, and all the objects are custom procedural meshes. Many many quads that I build in script. In my paper backplate inspector you can see that on the material I don't have the texture linked. Instead I have it linked on the main script and then I assign that texture to the material in Awake.

inspector

 void Awake ()
 {
     meshFilterComponent = GetComponent<MeshFilter>();
     Material material = GetComponent<MeshRenderer>().material;
     material.SetTexture(0, paperTexture);
     material.color = new Vector4(1f, 1f, 1f, 1f);
 }

When I hit play the script runs and the texture in the inspector changes from None to the paper texture. The mesh gets built in the script. Everything renders fine. But when I run it on the iPhone I suspect that it's not finding that paperTexture in the assets. It renders the quad all white. If I pre-link the Texture to the paper texture and then build it on the phone the texture renders correctly on the phone. But that doesn't work for me because in other cases (not this paper background) I need to be able to pick the appropriate texture programmatically. For example if I were to have skin-able themes or something.

Any clue why the texture wouldn't already be part of the project in iOS when it is linked to the Paper Texture property of the PaperBackplate script? Or why that would only be a problem on iOS and not when run in the unity interface.

Is there a way to make sure that a texture is going to be part of a project? Also where in the iOS project in Xcode do you find assets like textures? I'm not seeing them in the Xcode project anywhere even when it does render with the texture.

UPDATE

I changed my texture folder to "Resources" but that didn't fix it.

inspector.jpg (76.2 kB)
missingtextures.jpg (342.3 kB)
Comment
Add comment · Show 6
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 Owen-Reynolds · Mar 02, 2015 at 08:15 AM 0
Share

Is there anywhere where you load it differently? For example, just renderer.material=

If the paper texture is in a public script var, it should be in the build. I'm wondering if something funny is going on with the assignment ($$anonymous$$aterials like to secretly give you cloned instances.)

avatar image badweasel · Mar 02, 2015 at 11:11 AM 0
Share

Aren't I doing render.material= in my awake method? I do want instances of my material so I can have different textures on each one.

avatar image badweasel · Mar 02, 2015 at 11:34 AM 0
Share

I did try assigning it in the inspector and it does work that way. So as you say it's not the shader. I'm doing set texture 0 right now. In the morning I'll try it the way you suggest. Thanks for the advice.

avatar image badweasel · Mar 03, 2015 at 12:32 AM 0
Share

@Neamtzu, That fixed it. Write it as an answer so I can checkmark it.

avatar image Owen-Reynolds · Mar 03, 2015 at 12:39 AM 0
Share

What? Your screenshot clearly shows paperTexture was assigned in the Inspector, in the paperBackplate script.

Show more comments

1 Reply

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

Answer by Neamtzu · Mar 02, 2015 at 11:20 AM

Try to make a build with the textures assigned from the inspector. If it doesn't work, the problem is caused by the shaders. If it works, the problem is the assignment.

Btw, try to assign the texture like this: material.SetTexture("yourVariableName", bumpMap); - where yourVariableName is the name of the texture in shader.

Comment
Add comment · 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

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

Identical material with different textures 0 Answers

How do I get Texture from material 1 Answer

single texture atlas or multiple textures? 0 Answers

single texture atlas or multiple textures? 0 Answers

How do i add a texture material to my imported object? 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