public BuildSettingsExportCollection(IAssetExporter assetExporter, VirtualSerializedFile virtualFile, BuildSettings asset) : base(assetExporter, asset) { EditorBuildSettings = EditorBuildSettings.CreateVirtualInstance(virtualFile); EditorSettings = EditorSettings.CreateVirtualInstance(virtualFile); if (!NavMeshProjectSettings.IsReadNavMeshProjectSettings(asset.File.Version)) { NavMeshProjectSettings = NavMeshProjectSettings.CreateVirtualInstance(virtualFile); } if (!NetworkManager.IsReadNetworkManager(asset.File.Version)) { NetworkManager = NetworkManager.CreateVirtualInstance(virtualFile); } if (!Physics2DSettings.IsReadPhysics2DSettings(asset.File.Version)) { Physics2DSettings = Physics2DSettings.CreateVirtualInstance(virtualFile); } if (!UnityConnectSettings.IsReadUnityConnectSettings(asset.File.Version)) { UnityConnectSettings = UnityConnectSettings.CreateVirtualInstance(virtualFile); } if (!QualitySettings.IsReadQualitySettings(asset.File.Version)) { QualitySettings = QualitySettings.CreateVirtualInstance(virtualFile); } }
public SceneExportCollection(IAssetExporter assetExporter, string name, IEnumerable <Object> objects) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException(nameof(name)); } AssetExporter = assetExporter; Name = name; HashSet <string> exportIDs = new HashSet <string>(); foreach (Object @object in objects.OrderBy(t => t, this)) { AddObject(@object, exportIDs); } if (Config.IsGenerateGUIDByContent) { GUID = ObjectUtils.CalculateObjectsGUID(objects); } else { GUID = new UtinyGUID(new Guid()); } }
public void Export(string path, IEnumerable <Object> objects) { if (IsExporting) { throw new InvalidOperationException("Unable to start a new export process until the old one is completed"); } // speed up fetching a little bit List <Object> depList = new List <Object>(); HashSet <Object> depSet = new HashSet <Object>(); HashSet <Object> queued = new HashSet <Object>(); depList.AddRange(objects); depSet.UnionWith(depList); for (int i = 0; i < depList.Count; i++) { Object current = depList[i]; if (!queued.Contains(current)) { ClassIDType exportID = current.IsAsset ? current.ClassID : ClassIDType.Component; IAssetExporter exporter = m_exporters[exportID]; IExportCollection collection = exporter.CreateCollection(current); foreach (Object element in collection.Objects) { queued.Add(element); } m_collections.Add(collection); } #warning TODO: if IsGenerateGUIDByContent set it should build collections and write actual references with persistent GUIS, but skip dependencies if (Config.IsExportDependencies) { foreach (Object dep in current.FetchDependencies(true)) { if (!depSet.Contains(dep)) { depList.Add(dep); depSet.Add(dep); } } } } depList.Clear(); depSet.Clear(); queued.Clear(); foreach (IExportCollection collection in m_collections) { m_currentCollection = collection; bool isExported = collection.AssetExporter.Export(collection, path); if (isExported) { Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported"); } } m_currentCollection = null; m_collections.Clear(); }
public void Export(string path, IEnumerable <Object> objects) { List <IExportCollection> collections = new List <IExportCollection>(); // speed up fetching a little bit List <Object> depList = new List <Object>(); HashSet <Object> depSet = new HashSet <Object>(); HashSet <Object> queued = new HashSet <Object>(); depList.AddRange(objects); depSet.UnionWith(depList); for (int i = 0; i < depList.Count; i++) { Object current = depList[i]; if (!queued.Contains(current)) { ClassIDType exportID = current.IsAsset ? current.ClassID : ClassIDType.Component; IAssetExporter exporter = m_exporters[exportID]; IExportCollection collection = exporter.CreateCollection(current); foreach (Object element in collection.Objects) { queued.Add(element); } collections.Add(collection); } #warning TODO: if IsGenerateGUIDByContent set it should build collections and write actual references with persistent GUIS, but skip dependencies if (Config.IsExportDependencies) { foreach (Object dependency in current.FetchDependencies(true)) { if (dependency == null) { continue; } if (!depSet.Contains(dependency)) { depList.Add(dependency); depSet.Add(dependency); } } } } depList.Clear(); depSet.Clear(); queued.Clear(); AssetsExportContainer container = new AssetsExportContainer(this, collections); foreach (IExportCollection collection in collections) { container.CurrentCollection = collection; bool isExported = collection.AssetExporter.Export(container, collection, path); if (isExported) { Logger.Log(LogType.Info, LogCategory.Export, $"'{collection.Name}' exported"); } } }
public PrefabExportCollection(IAssetExporter assetExporter, Prefab prefab, IEnumerable <Object> objects) : base(assetExporter, prefab) { foreach (Object @object in objects) { AddObject(@object); } }
public void OverrideExporter(ClassIDType classType, IAssetExporter exporter) { if (exporter == null) { throw new ArgumentNullException(nameof(exporter)); } m_exporters[classType] = exporter; }
public PrefabExportCollection(IAssetExporter assetExporter, Prefab prefab, IEnumerable <EditorExtension> objects) : base(assetExporter, prefab) { foreach (EditorExtension @object in objects) { AddObject(@object); } }
private PrefabExportCollection(IAssetExporter assetExporter, IAssetContainer file, PrefabInstance prefab) : base(assetExporter, prefab) { foreach (EditorExtension asset in prefab.FetchObjects(file)) { AddAsset(asset); } }
private PrefabExportCollection(IAssetExporter assetExporter, ISerializedFile file, Prefab prefab) : base(assetExporter, prefab) { foreach (EditorExtension asset in prefab.FetchObjects(file)) { AddAsset(asset); } }
private PrefabExportCollection(IAssetExporter assetExporter, Prefab prefab) : base(assetExporter, prefab) { foreach (EditorExtension @object in prefab.FetchObjects().OrderBy(t => t, this)) { AddObject(@object); } }
public SceneExportCollection(IAssetExporter assetExporter, VirtualSerializedFile virtualFile, ISerializedFile file) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (file == null) { throw new ArgumentNullException(nameof(file)); } AssetExporter = assetExporter; Name = file.Name; m_file = file; List <Object> components = new List <Object>(); foreach (Object asset in file.FetchAssets()) { if (OcclusionCullingSettings.IsSceneCompatible(asset)) { components.Add(asset); m_cexportIDs.Add(asset.AssetInfo, asset.PathID); } } m_components = components.OrderBy(t => t, this).ToArray(); if (OcclusionCullingSettings.HasSceneGUID(file.Version)) { OcclusionCullingSettings sceneSettings = Components.Where(t => t.ClassID == ClassIDType.OcclusionCullingSettings).Select(t => (OcclusionCullingSettings)t).FirstOrDefault(); if (sceneSettings != null) { GUID = sceneSettings.SceneGUID; } } if (GUID.IsZero) { GUID = new UnityGUID(Guid.NewGuid()); } if (OcclusionCullingSettings.HasReadPVSData(File.Version)) { foreach (Object comp in Components) { if (comp.ClassID == ClassIDType.OcclusionCullingSettings) { OcclusionCullingSettings settings = (OcclusionCullingSettings)comp; if (settings.PVSData.Length > 0) { m_occlusionCullingSettings = settings; OcclusionCullingData = OcclusionCullingData.CreateVirtualInstance(virtualFile); break; } } } } }
public AnimatorControllerExportCollection(IAssetExporter assetExporter, VirtualSerializedFile virtualFile, AnimatorController asset) : base(assetExporter, asset) { ControllerConstant controller = asset.Controller; IReadOnlyList <OffsetPtr <StateMachineConstant> > stateMachinesConst = controller.StateMachineArray; StateMachines = new AnimatorStateMachine[stateMachinesConst.Count]; for (int i = 0; i < stateMachinesConst.Count; i++) { AnimatorStateMachine stateMachine = AnimatorStateMachine.CreateVirtualInstance(virtualFile, asset, i); StateMachines[i] = stateMachine; } for (int i = 0; i < StateMachines.Length; i++) { AnimatorStateMachine stateMachine = StateMachines[i]; StateMachineConstant stateMachineConstant = asset.Controller.StateMachineArray[i].Instance; AddAsset(stateMachine); AddBehaviours(asset, stateMachine.StateMachineBehaviours); foreach (PPtr <AnimatorStateTransition> transitionPtr in stateMachine.AnyStateTransitions) { AnimatorStateTransition transition = transitionPtr.GetAsset(virtualFile); AddAsset(transition); } foreach (PPtr <AnimatorTransition> transitionPtr in stateMachine.EntryTransitions) { AnimatorTransition transition = transitionPtr.GetAsset(virtualFile); AddAsset(transition); } for (int j = 0; j < stateMachine.ChildStates.Length; j++) { PPtr <AnimatorState> statePtr = stateMachine.ChildStates[j].State; AnimatorState state = statePtr.GetAsset(virtualFile); StateConstant stateConstant = stateMachineConstant.StateConstantArray[j].Instance; AddAsset(state); AddBehaviours(asset, state.StateMachineBehaviours); if (state.Motion.IsVirtual) { Motion motion = state.Motion.GetAsset(virtualFile); AddBlendTree(virtualFile, (BlendTree)motion); } for (int k = 0; k < state.Transitions.Length; k++) { PPtr <AnimatorStateTransition> transitionPtr = state.Transitions[k]; AnimatorStateTransition transition = transitionPtr.GetAsset(virtualFile); TransitionConstant transitionConstant = stateConstant.TransitionConstantArray[k].Instance; AddAsset(transition); } } } }
private PrefabExportCollection(IAssetExporter assetExporter, ISerializedFile file, Prefab prefab) : base(assetExporter, prefab) { File = file; Flags = file.Flags | TransferInstructionFlags.SerializeForPrefabSystem; foreach (EditorExtension asset in prefab.FetchObjects(file)) { AddAsset(asset); } }
public static IExportCollection CreateExportCollection(IAssetExporter assetExporter, Sprite asset) { Texture2D texture = asset.RD.Texture.FindAsset(asset.File); if (texture == null) { return(new FailExportCollection(assetExporter, asset)); } return(new TextureExportCollection(assetExporter, texture, true)); }
public ScriptExportCollection(IAssetExporter assetExporter, MonoScript script) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } AssetExporter = assetExporter; File = script.File; // find copies in whole project and skip them foreach (ISerializedFile file in script.File.Collection.Files) { foreach (Object asset in file.FetchAssets()) { if (asset.ClassID != ClassIDType.MonoScript) { continue; } MonoScript assetScript = (MonoScript)asset; MonoScript unique = assetScript; foreach (MonoScript export in m_unique) { if (assetScript.ClassName != export.ClassName) { continue; } if (assetScript.Namespace != export.Namespace) { continue; } if (assetScript.AssemblyName != export.AssemblyName) { continue; } unique = export; break; } m_scripts.Add(assetScript, unique); if (assetScript == unique) { m_unique.Add(assetScript); if (assetScript.IsScriptPresents()) { m_export.Add(assetScript); } } } } }
public void OverrideExporter(ClassIDType classType, IAssetExporter exporter) { if (exporter == null) { throw new ArgumentNullException(nameof(exporter)); } if (!m_exporters.ContainsKey(classType)) { m_exporters[classType] = new Stack <IAssetExporter>(2); } m_exporters[classType].Push(exporter); }
public static IExportCollection CreateExportCollection(IAssetExporter assetExporter, Sprite asset) { if (Config.IsConvertTexturesToPNG) { Texture2D texture = asset.RD.Texture.FindObject(asset.File); if (texture != null) { return(new TextureExportCollection(assetExporter, texture)); } } return(new SkipExportCollection(assetExporter, asset)); }
public AssetExportCollection(IAssetExporter assetExporter, Object asset) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (asset == null) { throw new ArgumentNullException(nameof(asset)); } AssetExporter = assetExporter; Asset = asset; }
public AssetExportCollection(IAssetExporter assetExporter, Object asset) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (asset == null) { throw new ArgumentNullException(nameof(asset)); } AssetExporter = assetExporter; Asset = asset; MetaImporter = new NativeFormatImporter(asset); }
public SkipExportCollection(IAssetExporter assetExporter, Object asset) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (asset == null) { throw new ArgumentNullException(nameof(asset)); } AssetExporter = assetExporter; Name = asset.GetType().Name; m_asset = asset; }
public SceneExportCollection(IAssetExporter assetExporter, ISerializedFile file) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (file == null) { throw new ArgumentNullException(nameof(file)); } AssetExporter = assetExporter; Name = file.Name; m_file = file; foreach (Object asset in file.FetchAssets()) { if (OcclusionCullingSettings.IsCompatible(asset)) { AddComponent(file, asset); } } m_cexportIDs = m_cexportIDs.OrderBy(t => t.Key, this).ToDictionary(t => t.Key, t => t.Value); if (OcclusionCullingSettings.IsReadSceneGUID(file.Version)) { OcclusionCullingSettings sceneSettings = Components.Where(t => t.ClassID == ClassIDType.OcclusionCullingSettings).Select(t => (OcclusionCullingSettings)t).FirstOrDefault(); if (sceneSettings == null) { GUID = new EngineGUID(Guid.NewGuid()); } else { GUID = sceneSettings.SceneGUID; } } else { if (Config.IsGenerateGUIDByContent) { GUID = ObjectUtils.CalculateObjectsGUID(Assets); } else { GUID = new EngineGUID(Guid.NewGuid()); } } }
public TextureExportCollection(IAssetExporter assetExporter, Texture2D texture, bool convert) : base(assetExporter, texture) { m_convert = convert; if (convert) { foreach (Object asset in texture.File.Collection.FetchAssets()) { switch (asset.ClassID) { case ClassIDType.Sprite: { Sprite sprite = (Sprite)asset; if (sprite.RD.Texture.IsAsset(sprite.File, texture)) { SpriteAtlas atlas = Sprite.HasRendererData(sprite.File.Version) ? sprite.SpriteAtlas.FindAsset(sprite.File) : null; m_sprites.Add(sprite, atlas); AddAsset(sprite); } } break; case ClassIDType.SpriteAtlas: { SpriteAtlas atlas = (SpriteAtlas)asset; if (atlas.RenderDataMap.Count > 0) { foreach (PPtr <Sprite> spritePtr in atlas.PackedSprites) { Sprite sprite = spritePtr.FindAsset(atlas.File); if (sprite != null) { SpriteAtlasData atlasData = atlas.RenderDataMap[sprite.RenderDataKey]; if (atlasData.Texture.IsAsset(atlas.File, texture)) { m_sprites.Add(sprite, atlas); AddAsset(sprite); } } } } } break; } } } }
public TextureExportCollection(IAssetExporter assetExporter, Texture2D texture, bool convert) : base(assetExporter, texture, CreateImporter(texture, convert)) { m_convert = convert; if (convert) { TextureImporter textureImporter = (TextureImporter)MetaImporter; Dictionary <Sprite, SpriteAtlas> sprites = new Dictionary <Sprite, SpriteAtlas>(); foreach (Object asset in texture.File.Collection.FetchAssets()) { switch (asset.ClassID) { case ClassIDType.Sprite: { Sprite sprite = (Sprite)asset; if (sprite.RD.Texture.IsAsset(sprite.File, texture)) { SpriteAtlas atlas = Sprite.IsReadRendererData(sprite.File.Version) ? sprite.SpriteAtlas.FindAsset(sprite.File) : null; sprites.Add(sprite, atlas); AddAsset(sprite); } } break; case ClassIDType.SpriteAtlas: { SpriteAtlas atlas = (SpriteAtlas)asset; foreach (PPtr <Sprite> spritePtr in atlas.PackedSprites) { Sprite sprite = spritePtr.FindAsset(atlas.File); if (sprite != null) { SpriteAtlasData atlasData = atlas.RenderDataMap[sprite.RenderDataKey]; if (atlasData.Texture.IsAsset(atlas.File, texture)) { sprites.Add(sprite, atlas); AddAsset(sprite); } } } } break; } } textureImporter.Sprites = sprites; } }
public AssetExportCollection(IAssetExporter assetExporter, Object asset, IYAMLExportable metaImporter) { if (assetExporter == null) { throw new ArgumentNullException(nameof(assetExporter)); } if (asset == null) { throw new ArgumentNullException(nameof(asset)); } if (metaImporter == null) { throw new ArgumentNullException(nameof(metaImporter)); } AssetExporter = assetExporter; Asset = asset; MetaImporter = metaImporter; }
public TextureExportCollection(IAssetExporter assetExporter, Texture2D texture, bool convert) : base(assetExporter, texture, CreateImporter(texture, convert)) { m_convert = convert; if (convert) { TextureImporter textureImporter = (TextureImporter)MetaImporter; List <Sprite> sprites = new List <Sprite>(); foreach (Object asset in texture.File.FetchAssets()) { switch (asset.ClassID) { case ClassIDType.Sprite: { Sprite sprite = (Sprite)asset; if (sprite.RD.Texture.IsAsset(sprite.File, texture)) { sprites.Add(sprite); AddAsset(sprite); } } break; case ClassIDType.SpriteAtlas: { int index = 0; SpriteAtlas atlas = (SpriteAtlas)asset; foreach (SpriteAtlasData atlasData in atlas.RenderDataMap.Values) { if (atlasData.Texture.IsAsset(atlas.File, texture)) { Sprite sprite = atlas.PackedSprites[index].GetAsset(atlas.File); sprites.Add(sprite); AddAsset(sprite); } index++; } } break; } } textureImporter.Sprites = sprites; } }
public TextureExportCollection(IAssetExporter assetExporter, Texture2D texture) : base(assetExporter, texture, CreateImporter(texture)) { if (MetaImporter is TextureImporter textureImporter) { List <Sprite> sprites = new List <Sprite>(); foreach (Object asset in texture.File.FetchAssets()) { if (asset.ClassID == ClassIDType.Sprite) { Sprite sprite = (Sprite)asset; if (sprite.RD.Texture.IsObject(sprite.File, texture)) { sprites.Add(sprite); AddAsset(sprite); } } } textureImporter.Sprites = sprites; } }
public AssetExportCollection(IAssetExporter assetExporter, Object asset) : this(assetExporter, asset, new NativeFormatImporter(asset)) { }
protected AssetsExportCollection(IAssetExporter assetExporter, Object asset, IAssetImporter metaImporter) : base(assetExporter, asset, metaImporter) { }
public PrefabExportCollection(IAssetExporter assetExporter, VirtualSerializedFile virtualFile, Object asset) : this(assetExporter, virtualFile, GetAssetRoot(asset)) { }
private PrefabExportCollection(IAssetExporter assetExporter, VirtualSerializedFile virtualFile, GameObject root) : this(assetExporter, root.File, Prefab.CreateVirtualInstance(virtualFile, root)) { }