Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add increment to materials with duplicate id #9294

Merged
merged 6 commits into from Oct 28, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 2 additions & 1 deletion dist/preview release/what's new.md
Expand Up @@ -377,4 +377,5 @@
- Fix width/height GUI container computation to take into account paddings when `adaptWithToChildren = true` ([Popov72](https://github.com/Popov72))
- `smoothstep` in NME is now taking any type of parameters for its `value` input. If you use generated code from the NME ("Generate code" button), you may have to move the smoothstep output connection AFTER the input connections ([Popov72](https://github.com/Popov72))
- `SoundTrack.RemoveSound` and `SoundTrack.AddSound` were renamed to `SoundTrack.removeSound` and `SoundTrack.addSound` ([Deltakosh](https://github.com/deltakosh))
- `PolygonPoints.add` no longer filters out points that are close to the first point ([bghgary](https://github.com/bghgary))
- `PolygonPoints.add` no longer filters out points that are close to the first point ([bghgary](https://github.com/bghgary))
- `Material` created with matching names now have auto-incrementing IDs.
7 changes: 6 additions & 1 deletion src/Materials/material.ts
Expand Up @@ -660,9 +660,14 @@ export class Material implements IAnimatable {
*/
constructor(name: string, scene: Scene, doNotAdd?: boolean) {
this.name = name;
let idSubscript = 1;
this._scene = scene || EngineStore.LastCreatedScene;

this.id = name || Tools.RandomId();
while (this._scene.getMaterialByID(this.id)) {
this.id = name + " " + idSubscript++;
}

this._scene = scene || EngineStore.LastCreatedScene;
this.uniqueId = this._scene.getUniqueId();

if (this._scene.useRightHandedSystem) {
Expand Down