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 hkessock · Dec 28, 2013 at 12:02 AM · iosshaders

Unity on iOS - Specular Shader

I'm creating materials in script and assigning them to objects in my scene and have not experience any problems on OSX/Windows, but when I build and deploy to iOS I am getting a crash in my coroutine that loads/creates scene resources.

The crash happens when creating materials, and it doesn't crash on the first material (which uses a mobile/bumped specular shader.)

The crash happens on the second material in the Material constructor using Shader.Find( "Specular" )

I'm not aware of any restriction on using non-mobile shaders (not withstanding performance concerns of course), so I am stumped as to why this is crashing.

I've not spend anytime debugging with XCode before so I am having a hard time finding the culprit error on "Material.cpp line 268" when my XCode project doesn't have *.cpp files and doesn't have any files named material with any extension...

I'm virtually certain this is some dumb "welcome to Unity iOS you noob" issue.

Anyone...?

Here's the offending portion of code right up until what XCode is telling me is the crash source:

 //Set materials for the frame
 l_oFrameRenderer.material = new Material( Shader.Find( "Mobile/Bumped Specular" ) );
 l_oFrameRenderer.material.name = "Titlebar Frame Material";
 l_oFrameRenderer.material.SetTexture( "_MainTex", l_oLeatherTexture );
 l_oFrameRenderer.material.SetTextureScale( "_MainTex", new Vector2( 7.0f, 7.0f ) );
 l_oFrameRenderer.material.SetTexture( "_BumpMap", l_oLeatherNormalMap );
 l_oFrameRenderer.material.SetTextureScale( "_BumpMap", new Vector2( 7.0f, 7.0f ) );
 
 //Set materials for the inset - POP - Exception when the following line executes...
 l_oInsetRenderer.material = new Material( Shader.Find( "Specular" ) );
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 hkessock · Dec 28, 2013 at 12:38 AM 0
Share

Checking the return value of Shader.Find( "Specular" ) reveals that the value is NULL...

Is there some sort of packaging magic I need to enable to put the default shaders on an iOS device? It seems that the ones in the 'mobile' subdirectory are automatically deployed... Anyone know where this is configured...?

avatar image hkessock · Dec 28, 2013 at 12:40 AM 0
Share

Hmmm... I wonder if it is because it isn't referenced anywhere outside of my scripts. I have a default material with the $$anonymous$$obile/Bumped Specular on it, and that one doesn't seem to be missing. Will try adding a material with Specular on it...

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by hkessock · Dec 28, 2013 at 12:50 AM

I don't know if this is a bug or a procedural error on my part, but the solution to this problem is to simply create a dummy material in your project that references each shader you plan to make use of from script. Sounds like bug, but a bug resulting from the Unity team just not having the luxury of looking around for stuff to finish adding ;).

So, remember folks, if you're going to create materials from script, make sure those shaders were referenced somewhere in your project outside of a script. Then again, I may be missing some simple method of letting Unity know that I want to use these shaders.

Comment
Add comment · Show 1 · 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 semiessessi · Feb 07, 2014 at 04:04 PM 0
Share

it is documented that resources are included in the package based on the hierarchies in scene files. so if its not referred to in any of those it won't get included unless its in one of the special paths that unity always includes - which includes at least Resources and Strea$$anonymous$$gAssets at least.

also don't cut the unity guys too much slack. this isn't a bug, but they also have imo totally failed to deliver a particularly good game engine to go with an otherwise fantastic editor.

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

19 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

Related Questions

iOS DepthTextureMode.DepthNormals mode support 0 Answers

The name 'Joystick' does not denote a valid type ('not found') 2 Answers

Alternatives for using vertex colors + vertex lighting, IOS 1 Answer

Do i need to make asset bundles with upgraded Unity version? 0 Answers

Meshes not being rendered on iPhone 5, but working on any other iOS device 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