private void ResolveReference(Scene.Mapping mapping, GameObject value) { if (value != null) { uint object_id; int object_part; List <GameObject> parts; if (mapping.Go2Id.TryGetValue(value, out object_id) && mapping.Id2Go.TryGetValue(object_id, out parts)) { object_part = parts.FindIndex(x => value == x); if (object_part >= 0) { id = object_id; part = (uint)object_part; resolved = true; } else { throw new ArgumentException(); } } else { throw new ArgumentException(); } } }
public void ResolveReference(Scene.Mapping ids, Dictionary <UnityEngine.Mesh, int> meshes, Dictionary <UnityEngine.Material, int> materials, Dictionary <Texture2D, int> textures) { try { switch (GetSupportedType()) { case SupportedType.GAMEOBJECT: ResolveReference(ids, unityValue as GameObject); break; case SupportedType.COMPONENT: ResolveReference(ids, (unityValue as Component).gameObject); break; case SupportedType.MESH: ResolveReference(meshes, unityValue as UnityEngine.Mesh); break; case SupportedType.MATERIAL: ResolveReference(materials, unityValue as UnityEngine.Material); break; case SupportedType.TEXTURE: ResolveReference(textures, unityValue as Texture2D); break; default: Debug.LogWarningFormat("Unhandled reference to unity object '{0}' of type '{1}'.", unityValue.name, type); break; } } catch (ArgumentException) { Debug.LogWarningFormat("Unhandled reference to unity object '{0}' of type '{1}'. Reference to external asset not supported.", unityValue.name, type); } }