How to get the material instance id?

How to get the material instance id?

xiesansi
Enthusiast Enthusiast
748 Views
4 Replies
Message 1 of 5

How to get the material instance id?

xiesansi
Enthusiast
Enthusiast

Hi,

 

I have 2 materials with the same material name.

 

I'm trying to differentiate between them. I tried GetHandleByAnim, but as the document said, the handle did not "saved with the scene, and no guarantees are provided about handle values from one load to another."

 

How to get a persistent id of a material?

 

xiesansi_0-1651918172003.png

 

0 Likes
Accepted solutions (1)
749 Views
4 Replies
Replies (4)
Message 2 of 5

denisT.MaxDoctor
Advisor
Advisor

In general, when working with materials, you should avoid naming different materials by the same name. But it may be the case that we don't know and you must do it. Well...there are three most common ways to identify such scene objects, other than using their exact name:

   #0 use base name and unique id

   #1 use app data channel

   #2 use custom attribute

 

0 Likes
Message 3 of 5

xiesansi
Enthusiast
Enthusiast

Thank you!

 

I prefer the first one since It would be better if I do not change the users' data...

Could you explain more about the unique id if animHandle does not work... Which method should I use?...

 

0 Likes
Message 4 of 5

xiesansi
Enthusiast
Enthusiast

any one could help me with the id issue? Which method should I use to get a unique id?

0 Likes
Message 5 of 5

denisT.MaxDoctor
Advisor
Advisor
Accepted solution

@xiesansi wrote:

any one could help me with the id issue? Which method should I use to get a unique id?


rename materials by giving them a unique ID. use for example 

genClassID

 to generate unique and random ids.

0 Likes