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 melonkuantum · Apr 08, 2014 at 06:39 AM · particlesystemmaterialpropertyblock

Modify [PerRendererData] texture in ParticleSystem (Shuriken)

Hi,

Currently I'm working on a 2d game that can change between day / night cycle. At night, all foreground object will be changed to dark silhouette.

I achieve this effect by creating custom material that use Sprite/Default shader and assign this material to all foreground objects. When the cycle change I just need to change sharedMaterial color of one of the object.

It works beautifully but I encounter problem when I add ParticleSystem since it seems that it doesn't provide a way to fill the texture for my material.

I've tried attaching this script to the object:


public Texture tex;
ParticleSystem ps;
void Awake () {
    MaterialPropertyBlock mpb = new MaterialPropertyBlock ();
    mpb.AddTexture ("_MainTex", tex);
    ps = GetComponent< ParticleSystem > ();
    ps.renderer.SetPropertyBlock (mpb);
}

But even though the texture of the material is changed, the ParticleSystem is still emitting a white square.

Is it possible to change the texture this way? Are there any workaround for this?

Thanks.

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

3 Replies

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

Answer by melonkuantum · Apr 11, 2014 at 04:32 PM

For those who encounter similar problem.

I still can't change the texture emitted by ParticleSystem, but I found a way to achieve same effect (dark silhouette) without changing sharedMaterial. Instead of using Sprites/Default, use Sprites/Diffuse.

This way you can change all material using Sprites/Diffuse to dark silhouette with 1 line of code only by changing RenderSettings.ambientLight and you can use different material for particle, no need for MaterialPropertyBlock.

Regards.

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
avatar image
0

Answer by Razieln64 · May 09, 2014 at 03:07 AM

Hi,

there seems to be a problem when setting a material property block on a ParticleSystemRenderer. It is also an issue for me. I need to change a color but I'll probably do it through the vertex colors. Hopefully Unity will fix this.

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
avatar image
0

Answer by benblo · Dec 04, 2014 at 02:57 PM

That would be psr = GetComponent< ParticleSystemRenderer >();, not ParticleSystem. But anyway it doesn't seem to work for me either so I'm getting ParticleSystemRenderer just doesn't support property blocks :( ...

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

23 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 avatar image

Related Questions

Materialpropertyblock cannot work at ParticleSystemRenderer's 「Mesh」RenderMode? 1 Answer

SetPropertyBlock doesn't work for particle systems? 0 Answers

Spawning Particle Systems for Gun Sparks 1 Answer

Particle Collision Mesh Occlusion 1 Answer

What would be the "next-best-thing" to a ParticleSystem? 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