mirror of
https://github.com/bdunderscore/modular-avatar.git
synced 2025-03-09 15:24:58 +08:00
fix: issues with build failures when there are duplicate object paths (#398)
This commit is contained in:
parent
5a5142bf62
commit
0335c31725
@ -0,0 +1,21 @@
|
||||
using modular_avatar_tests;
|
||||
using nadena.dev.modular_avatar.core.editor;
|
||||
using NUnit.Framework;
|
||||
|
||||
namespace _ModularAvatar.EditModeTests
|
||||
{
|
||||
public class DuplicateObjectNameTest : TestBase
|
||||
{
|
||||
[Test]
|
||||
public void test_duplicate_object_names()
|
||||
{
|
||||
var avatar = CreateRoot("root");
|
||||
var c1 = CreateChild(avatar, "child");
|
||||
var c2 = CreateChild(avatar, "child");
|
||||
|
||||
PathMappings.Init(avatar);
|
||||
c2.gameObject.name = "child2";
|
||||
Assert.AreEqual(PathMappings.MapPath("child"), "child");
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,3 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3ef07dec7e1d439586f2b925d89483b8
|
||||
timeCreated: 1692505855
|
@ -1,18 +1,18 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
*
|
||||
* Copyright (c) 2022 bd_
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
@ -25,6 +25,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Immutable;
|
||||
using NUnit.Framework;
|
||||
using Serilog.Sinks.File;
|
||||
using UnityEditor;
|
||||
using UnityEngine;
|
||||
using VRC.SDKBase.Editor.BuildPipeline;
|
||||
@ -150,7 +151,7 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
{
|
||||
if (cache != null) return cache;
|
||||
|
||||
ImmutableDictionary<string, string>.Builder builder = ImmutableDictionary.CreateBuilder<string, string>();
|
||||
ImmutableDictionary<string, string> dict = ImmutableDictionary<string, string>.Empty;
|
||||
|
||||
foreach (var kvp in _objectToOriginalPaths)
|
||||
{
|
||||
@ -168,11 +169,14 @@ namespace nadena.dev.modular_avatar.core.editor
|
||||
var newPath = RuntimeUtil.AvatarRootPath(obj);
|
||||
foreach (var origPath in paths)
|
||||
{
|
||||
builder.Add(origPath, newPath);
|
||||
if (!dict.ContainsKey(origPath))
|
||||
{
|
||||
dict = dict.Add(origPath, newPath);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cache = builder.ToImmutableDictionary();
|
||||
cache = dict;
|
||||
return cache;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user