public GameObject OccupyObject(string guid, string name, GameObject parentObject) { GameObject found = null; if (guid != null) { found = FindFreeObjectFromXdGuid(guid); } if (found == null && name != null) { // Debug.Log($"guidで見つからなかった:{name}"); var founds = FindFreeObjectsByName(name, parentObject); if (founds == null || founds.Count == 0) { return(null); } found = founds[0]; } if (found != null) { FreeChildObjects.Remove(found); } return(found); }
public void AddFreeObject(GameObject obj) { // 後の名前検索で正確にできるように/を前にいれる var name = "/" + obj.name; var parent = obj.transform.parent; while (parent) { name = "/" + parent.name + name; parent = parent.parent; } // XdGuidコンポーネントがある場合、Guidも情報にいれる string xdGuid = null; var xdGuidComponent = obj.GetComponent <XdGuid>(); if (xdGuidComponent != null) { xdGuid = xdGuidComponent.guid; } FreeChildObjects.Add(obj, new GameObjectIdentifier(name, xdGuid)); }