public object ReadContent(IAssetProvider assetManager, ref ContentReaderParameters parameters) { var shaderCollection = new ShaderCollection(); try { var bs = new BinarySerializer(parameters.Stream, SerializerMode.Read) { AllowIdentity = true }; bs.Serialize(ref shaderCollection); } catch (SerializationException e) { LogEvent.Tool.Error(e.Message); throw; } return(shaderCollection); }
/// <summary> /// 生成所有资源 /// </summary> /// <param name="outputPath"></param> /// <param name="platform"></param> /// <param name="target"></param> static public void GenAllAssets(string outputPath, RuntimePlatform platform, BuildTarget target) { var _outputPath = Path.Combine(outputPath, BDApplication.GetPlatformPath(platform)); // + "/" + ; if (Directory.Exists(_outputPath)) { Directory.Delete(_outputPath, true); } //1.打包资源 try { //1.搜集keywork ShaderCollection.GenShaderVariant(); //2.打包模式 var config = BDEditorApplication.BdFrameEditorSetting.BuildAssetConfig; AssetBundleEditorToolsV2.GenAssetBundle(outputPath, platform, target, BuildAssetBundleOptions.ChunkBasedCompression, config.IsUseHashName, config.AESCode); } catch (Exception e) { Debug.LogError(e.Message); } //2.编译脚本 try { EditorWindow_ScriptBuildDll.RoslynBuild(outputPath, platform, ScriptBuildTools.BuildMode.Release); } catch (Exception e) { Debug.LogError(e.Message); } //3.打包表格 try { Excel2SQLiteTools.AllExcel2SQLite(outputPath, platform); } catch (Exception e) { Debug.LogError(e.Message); } }
/// <summary> /// 生成所有资源 /// </summary> /// <param name="exportPath"></param> /// <param name="platform"></param> /// <param name="target"></param> static public void GenAllAssets(string exportPath, RuntimePlatform platform, BuildTarget target) { var outPath = exportPath + "/" + BApplication.GetPlatformPath(platform); if (Directory.Exists(outPath)) { Directory.Delete(outPath, true); } //1.打包资源 try { //搜集keywork ShaderCollection.GenShaderVariant(); AssetBundleEditorTools.GenAssetBundle(outPath, target); } catch (Exception e) { Debug.LogError(e.Message); return; } //2.编译脚本 try { EditorWindow_ScriptBuildDll.RoslynBuild(ScriptBuildTools.BuildMode.Release, outPath); } catch (Exception e) { Debug.LogError(e.Message); return; } //3.打包表格 try { Excel2SQLiteTools.GenExcel2SQLite(exportPath, platform); } catch (Exception e) { Debug.LogError(e.Message); } }
public static ForaysWindow Create(int cols, int rows) { ToolkitOptions.Default.EnableHighResolution = false; //todo - actually test this line, since it might not apply any more. ForaysWindow w = new ForaysWindow(DisplayDevice.Default.Width, DisplayDevice.Default.Height, "Forays into Norrendrin"); w.VSync = VSyncMode.Off; //todo icon //todo, create a RNG for the UI and use it here: w.TimerFramesOffset = -8888888; w.SetWorldUnitsPerScreen(cols, rows); w.TextSurface = Surface.Create(w, @"Forays.UI.ScreenUI.GL.vga9_msdf.png", TextureMinFilter.Nearest, TextureMagFilter.Linear, TextureLoadSource.FromEmbedded, null, ShaderCollection.GetMsdfFS(2048, 4), false, 2, 4, 4); w.TextSurface.texture.Sprite.Add(GetIbmFontSpriteType()); CellLayout.CreateGrid(w.TextSurface, cols, rows); w.TextSurface.InitializePositions(cols * rows); w.TextSurface.InitializeOtherDataForSingleLayout(cols * rows, 0, 32, Color.Black.GetRGBA(), Color.Black.GetRGBA()); w.CursorSurface = Surface.Create(w, @"Forays.UI.ScreenUI.GL.vga9_msdf.png", TextureMinFilter.Nearest, TextureMagFilter.Linear, TextureLoadSource.FromEmbedded, null, ShaderCollection.GetMsdfFS(2048, 4), false, 2, 4, 4); //todo could be a bit off, but probably works w.CursorSurface.texture.Sprite = w.TextSurface.texture.Sprite; // Share the sprite definition as well as the texture index CellLayout.CreateGrid(w.CursorSurface, 1, 1, 0.8f, 0.125f, 0.0f, 0.75f); //todo, tweak later w.CursorSurface.InitializePositions(1); w.CursorSurface.InitializeOtherDataForSingleLayout(1, 0, 0, Color.Gray.GetRGBA(), Color.Black.GetRGBA()); w.CursorSurface.Disabled = true; //todo check GL.Enable(EnableCap.Blend); //todo verify needed GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha); //todo verify needed w.WindowSizeRules = new ResizeRules { MinWidth = 800, MinHeight = 600 }; //todo, ratio? //todo make configurable? w.ViewportSizeRules = null; //todo add viewport rules w.NoShrinkToFit = false; //todo, closing handler? w.Visible = true; return(w); }
public override void Initialize() { Contract.Requires <InvalidOperationException>(AssetName != null); ShaderCollection shaderCollection = Content.Load <ShaderCollection>(AssetName); var techniquePool = DeviceService.DirectXDevice.TechniquePool; var mapping = shaderCollection.Get(Key); string techniqueKey = string.Format("{0}.{1}", AssetName, mapping.Name); if (!techniquePool.ContainsTechnique(techniqueKey)) { Technique = new Technique(DeviceService.DirectXDevice, techniqueKey, mapping); techniquePool.RegisterTechnique(Technique); Messenger.Send(new ContentMessage <Technique>(Owner, AssetName, Technique)); } else { Technique = techniquePool.GetTechnique(techniqueKey); } }
public override void Initialize() { var techniquePool = DeviceService.DirectXDevice.TechniquePool; var filteredActions = (from a in actions where a.AssetName != Param.Engine select new { Asset = a.AssetName, Technique = a.Technique }).Distinct().ToArray(); techniques = new Technique[filteredActions.Length]; for (int i = 0; i < filteredActions.Length; i++) { var action = filteredActions[i]; ShaderCollection shaderCollection = Content.Load <ShaderCollection>(action.Asset); var mapping = shaderCollection.Get(action.Technique); string techniqueKey = string.Format("{0}.{1}", action.Asset, mapping.Name); if (!techniquePool.ContainsTechnique(techniqueKey)) { techniques[i] = new Technique(DeviceService.DirectXDevice, techniqueKey, mapping); techniquePool.RegisterTechnique(techniques[i]); // Notifies other systems that a new technique is ready to be initialized Messenger.Send(new ContentMessage <Technique>(Owner, action.Asset, techniques[i])); } else { techniques[i] = techniquePool.GetTechnique(techniqueKey); } } var settings = Services.GetService <IDirectXDeviceSettings>(); OutputWidth = settings.PreferredBackBufferWidth; OutputHeight = settings.PreferredBackBufferHeight; }
public static void Read(string fullPath, out ShaderCollection shaderCollection) { shaderCollection = ShaderCollection.Load(fullPath); }
public static void Serialize(string fullPath, ShaderCollection shaderCollection) { ShaderCollection.Save(fullPath, shaderCollection); }
public void SetTechnique(ShaderCollection shaderCollection, string techniqueKey) { this.shaderCollection = shaderCollection; this.techniqueKey = techniqueKey; }
/// <summary> /// 预览结果 编辑器连线数据,但是build模式也会执行 /// 这里只建议设置BuildingCtx的ab颗粒度 /// </summary> /// <param name="target"></param> /// <param name="nodeData"></param> /// <param name="incoming"></param> /// <param name="connectionsToOutput"></param> /// <param name="outputFunc"></param> public override void Prepare(BuildTarget target, NodeData nodeData, IEnumerable <PerformGraph.AssetGroups> incoming, IEnumerable <ConnectionData> connectionsToOutput, PerformGraph.Output outputFunc) { if (incoming == null) { return; } this.BuildingCtx = BDFrameworkAssetsEnv.BuildingCtx; StopwatchTools.Begin(); //收集变体 if (!isCollectedShaderKW) //防止GUI每次调用prepare时候都触发,真正打包时候 会重新构建 { Debug.Log("------------>收集Key word"); ShaderCollection.CollectShaderVariant(); isCollectedShaderKW = true; } //开始搜集传入的 shader varint var outMap = new Dictionary <string, List <AssetReference> >(); var incomingShaderAndVariantList = new List <AssetReference>(); var dependice = AssetDatabase.GetDependencies(BResources.ALL_SHADER_VARAINT_ASSET_PATH); var dependShaders = dependice.Where((depend) => { var type = AssetDatabase.GetMainAssetTypeAtPath(depend); if (type == typeof(Shader) || type == typeof(ShaderVariantCollection)) { //Debug.LogError("【搜集Shader】剔除非shader文件" + type.FullName); return(true); } return(false); }); //遍历传入的并且移除shader需要的 foreach (var ags in incoming) { foreach (var group in ags.assetGroups) { //拷贝一份 var newList = group.Value.ToList(); // for (int i = newList.Count - 1; i >= 0; i--) { //不直接操作传入的容器存储 var af = newList[i]; var ret = dependShaders.FirstOrDefault((dp) => dp.Equals(af.importFrom, StringComparison.OrdinalIgnoreCase)); if (ret != null) { newList.RemoveAt(i); incomingShaderAndVariantList.Add(af); } else { if (af.assetType == typeof(Shader)) { Debug.LogError($"【搜集KeyWord】 : {af.importFrom},请检查是否直接引用了FBX这类,SubAsset中有Mat的资产,如是请Ctrl+D复制引用!"); //寻找遗漏查找依赖资源 this.BuildingCtx.BuildingAssetInfos.AssetInfoMap.TryGetValue(af.importFrom, out var shaderAssetData); if (shaderAssetData != null) { var returnBD = this.BuildingCtx.BuildingAssetInfos.AssetInfoMap.FirstOrDefault((bd) => bd.Value.DependAssetList.Contains(shaderAssetData.ABName) || bd.Value.DependAssetList.Contains(af.importFrom, StringComparer.Ordinal)); if (returnBD.Value != null) { Debug.LogError("主资源:" + returnBD.Key); } } } } } //输出 outMap[group.Key] = newList; } } //依赖shader if (incomingShaderAndVariantList.Count > 0) //0的情况一般为 调试模式~ { foreach (var dependShader in dependShaders) { var retsult = incomingShaderAndVariantList.Find((ar) => ar.importFrom.Equals(dependShader, StringComparison.OrdinalIgnoreCase)); if (retsult == null) { var af = AssetReference.CreateReference(dependShader); incomingShaderAndVariantList.Add(af); Debug.LogError("没传入的依赖shader 单独添加:" + dependShader); } } } //设置ab foreach (var sharder in incomingShaderAndVariantList) { this.BuildingCtx.BuildingAssetInfos.SetABName(sharder.importFrom, AssetBundleName, BuildingAssetInfos.SetABNameMode.Force); } StopwatchTools.End("【搜集KeyWord】"); //输出shader outMap[nameof(BDFrameworkAssetsEnv.FloderType.Shaders)] = incomingShaderAndVariantList; //输出 var output = connectionsToOutput?.FirstOrDefault(); if (output != null) { outputFunc(output, outMap); } }
/// <summary> /// 最新包 /// </summary> void LastestGUI() { GUILayout.BeginVertical(); if (GUILayout.Button("检测资源", GUILayout.Width(100))) { exportPath = EditorUtility.OpenFolderPanel("选择导出目录", Application.dataPath, ""); if (string.IsNullOrEmpty(exportPath)) { return; } if (isSelectWindows) { AssetBundleEditorTools.CheackAssets(rootResourceDir, exportPath + "/Windows", BuildTarget.StandaloneWindows); } if (isSelectAndroid) { AssetBundleEditorTools.CheackAssets(rootResourceDir, exportPath + "/Android", BuildTarget.Android); } if (isSelectIOS) { AssetBundleEditorTools.CheackAssets(rootResourceDir, exportPath + "/iOS", BuildTarget.iOS); } AssetDatabase.Refresh(); Debug.Log("资源打包完毕"); } if (GUILayout.Button("收集Shader keyword", GUILayout.Width(200))) { ShaderCollection.GenShaderVariant(); } if (GUILayout.Button("一键打包[美术资源]", GUILayout.Width(380), GUILayout.Height(30))) { var exportPath = EditorUtility.OpenFolderPanel("选择导出目录", Application.dataPath, ""); if (string.IsNullOrEmpty(exportPath)) { return; } //开始打包 if (isSelectWindows) { AssetBundleEditorTools.GenAssetBundle(rootResourceDir, exportPath + "/Windows", BuildTarget.StandaloneWindows, options); } if (isSelectAndroid) { AssetBundleEditorTools.GenAssetBundle(rootResourceDir, exportPath + "/Android", BuildTarget.Android, options); } if (isSelectIOS) { AssetBundleEditorTools.GenAssetBundle(rootResourceDir, exportPath + "/iOS", BuildTarget.iOS, options); } AssetDatabase.Refresh(); Debug.Log("资源打包完毕"); } GUILayout.EndVertical(); }
public ShaderCollectionMesage(ShaderCollection shaderCollection) { ShaderCollection = shaderCollection; }