• 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 KEric · Mar 28, 2014 at 08:49 AM · materialparticlescolormaterialsrenderer

Does Material.color, ParticleSystem.startcolor property clones/copies the material?

Based on the manual [1] the change to the material will make a new instance of it - "this will clone the shared material". Does the renderer.material.color creates a new clone? Or the new clone instance is only created when assigning to the material property via renderer.material = ...?

Also the same story with ParticleSystem.startColor property, does material stays the same or is it cloned when triggered?

I'm asking the question because in the game I'm working on I'm using the pooling technique on a ParticleSystem objects. When an object is required I fetch it from the pool and assign the startColor based on some game logic, before triggering Play() function. The problem is that sometimes colors simply doesn't match, perhaps because the state of the previous usage still lingers.

[1] http://docs.unity3d.com/Documentation/ScriptReference/Renderer-material.html

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

2 Replies

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

Answer by KEric · Mar 28, 2014 at 09:23 AM

Ok, solution... Of course I've already had it, just before I've started making my particle systems "poolable". Yes it does a copy. In my case, the issue was with startColor property, I've simply made the usage of ParticleSystem.renderer.material.color rather then ParticleSystem.startColor and that did the trick. Works flawless, finally...

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 OSG · Mar 28, 2014 at 09:09 AM

As I know renderer.material.color copyes material and makes new instance of it. I worked with this problem in my game.
You can read my question.

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 KEric · Mar 28, 2014 at 09:24 AM 0
Share

Thanks for a comment, second ago just figured the solution out

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.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



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

Changing two different objects renderer colour 1 Answer

Adjust tint color of particles/additive? 2 Answers

Material doesn't have a color property '_Color' 4 Answers

Index array is out of range (following H&S tut) 2 Answers

Having a problem with the second material (on the same renderer) 0 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges