x


Shader Missing in Builds When Called From Shader.Find("")

I have a script that draws up a reference to a shader by name via Shader.Find(), and it displays fine in the editor, yet when I build it for the web player OR standalone PC the object displays in solid pink. Thus it appears that the builder doesn't know it needs to be included in your build. Is there a way to mark it to be force-included?

more ▼

asked Mar 01 '12 at 02:21 AM

blitzen gravatar image

blitzen
180 21 31 34

(I tried to edit the question with this new realization but it seems the forum is broken and won't apply editing changes.)

I have a script that draws up a reference to the shader by name via Shader.Find(), and so that is the only reference to it from the program - thus it appears that the builder doesn't know it needs to be included in your build. Is there a way to mark it to be force-included?

Mar 01 '12 at 03:07 AM blitzen

keep ur shader in resource folder it will be included no matter wat happens

Mar 01 '12 at 03:30 AM flamy
(comments are locked)
10|3000 characters needed characters left

2 answers: sort voted first

Nothing to do with 3.5; the shader needs to be included somehow that forces it to be part of the build. It's in your project, so it will always work in the editor. Finding things with strings won't do it, since it's very hard to tell what all possible combinations are. i.e., Shader.Find("foobar"); could be done as var a = "foo"; var b = "bar"; Shader.Find(a+b);. So Shader.Find won't cause a shader to be included, since Unity doesn't know it's being referred to. Instead, use the shader in a material on some object that's in the scene, or use it in a material that's in the Resources folder, since everything in Resources is always included whether it's used or not.

more ▼

answered Mar 01 '12 at 03:17 AM

Eric5h5 gravatar image

Eric5h5
80.1k 41 132 519

Looks like we were posting answers at the same time. Good call.

Mar 01 '12 at 03:32 AM blitzen
(comments are locked)
10|3000 characters needed characters left

Solved as per a related post by placing the shader asset in Assets/Resources, which ensures it gets included in builds even when not directly linked to.

more ▼

answered Mar 01 '12 at 03:20 AM

blitzen gravatar image

blitzen
180 21 31 34

Where are the built-in shader assets? Can you get at them without downloading their source code?

The way I typically get built-in shaders into my project is by assigning them to materials that I don't actually use, and them putting those materials into a Resources folder. There must be a better way?

May 02 at 01:08 PM shavais
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

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

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x1650
x810
x5

asked: Mar 01 '12 at 02:21 AM

Seen: 1174 times

Last Updated: May 02 at 01:08 PM