// Undocumented magic method to support nested prefab dependencies. Temporary solution until we get Asset Database V2 static string[] GatherDependenciesFromSourceFile(string assetPath) { var syncPrefab = PlayerFile.Load <SyncPrefab>(assetPath); var paths = new string[syncPrefab.Instances.Count]; var assetName = SanitizeName(syncPrefab.Name); for (var i = 0; i < syncPrefab.Instances.Count; ++i) { paths[i] = GetReferencedAssetPath(assetName, assetPath, syncPrefab.Instances[i].ObjectId.Value); } return(paths); }
public override void OnImportAsset(AssetImportContext ctx) { var syncPrefab = PlayerFile.Load <SyncPrefab>(ctx.assetPath); Init(syncPrefab.Name); var root = SyncPrefabImporter.Import(syncPrefab, this); var names = new List <string>(); SetUniqueNameForRoots(root, ref names); // TODO Find a deterministic way to avoid name collisions. RemapMaterials(root); ctx.AddObjectToAsset("root", root.gameObject); ctx.SetMainObject(root.gameObject); }
public override void OnImportAsset(AssetImportContext ctx) { var syncTexture = PlayerFile.Load <SyncTexture>(ctx.assetPath); var syncedData = new SyncedData <SyncTexture>(StreamKey.FromSyncId <SyncTexture>(ReflectScriptedImporter.EditorSourceId, syncTexture.Id), syncTexture); var textureImporter = new SyncTextureImporter(); var texture = textureImporter.Import(syncedData, null); texture.name = Path.GetFileNameWithoutExtension(syncTexture.Name); ctx.AddObjectToAsset("texture", texture); var root = ScriptableObject.CreateInstance <ReflectScriptableObject>(); ctx.AddObjectToAsset("root", root, AssetPreview.GetMiniThumbnail(texture)); ctx.SetMainObject(root); }
internal static SyncPrefab GenerateSyncPrefabFromManifest(string name, string rootFolder, SyncManifest manifest) { var prefab = new SyncPrefab { Name = name }; var content = manifest.Content; foreach (var pair in content) { if (pair.Key.IsKeyFor<SyncObjectInstance>()) { // Load SynObjectInstance from disk var instancePath = Path.Combine(rootFolder, pair.Value.ModelPath); var objectInstance = PlayerFile.Load<SyncObjectInstance>(instancePath); objectInstance.Name = Path.GetFileNameWithoutExtension(objectInstance.Name); prefab.Instances.Add(objectInstance); } } return prefab; }
public override void OnImportAsset(AssetImportContext ctx) { var syncMaterial = PlayerFile.Load <SyncMaterial>(ctx.assetPath); Init(syncMaterial.Name); var syncedData = new SyncedData <SyncMaterial>(StreamKey.FromSyncId <SyncMaterial>(EditorSourceId, syncMaterial.Id), syncMaterial); var materialImporter = new SyncMaterialImporter(); var material = materialImporter.Import(syncedData, this); material.name = Path.GetFileNameWithoutExtension(syncMaterial.Name); ctx.AddObjectToAsset("material", material); var root = ScriptableObject.CreateInstance <ReflectScriptableObject>(); ctx.AddObjectToAsset("root", root, AssetPreview.GetMiniThumbnail(material)); ctx.SetMainObject(root); }
public override void OnImportAsset(AssetImportContext ctx) { var syncMesh = PlayerFile.Load <SyncMesh>(ctx.assetPath); var syncedData = new SyncedData <SyncMesh>(StreamKey.FromSyncId <SyncMesh>(ReflectScriptedImporter.EditorSourceId, syncMesh.Id), syncMesh); var meshImporter = new SyncMeshImporter(); var mesh = meshImporter.Import(syncedData, null); if (m_GenerateLightmapUVs) { Unwrapping.GenerateSecondaryUVSet(mesh); } mesh.name = Path.GetFileNameWithoutExtension(syncMesh.Name); ctx.AddObjectToAsset("mesh", mesh); var root = ScriptableObject.CreateInstance <ReflectScriptableObject>(); ctx.AddObjectToAsset("root", root, AssetPreview.GetMiniThumbnail(mesh)); ctx.SetMainObject(root); }
public override void OnImportAsset(AssetImportContext ctx) { var sceneElement = PlayerFile.Load <SyncObject>(ctx.assetPath); Init(sceneElement.Name); var defaultMaterial = ReflectMaterialManager.defaultMaterial; var syncedData = new SyncedData <SyncObject>(StreamKey.FromSyncId <SyncObject>(EditorSourceId, sceneElement.Id), sceneElement); var elementImporter = new SyncObjectImporter(); var root = elementImporter.Import(syncedData, new SyncObjectImportConfig { settings = new SyncObjectImportSettings { defaultMaterial = defaultMaterial, importLights = m_ImportLights }, materialCache = this, meshCache = this }); SetUniqueNames(root.transform); // TODO Find a deterministic way to avoid name collisions. ctx.AddObjectToAsset("root", root); ctx.SetMainObject(root); }