public void OnProgressReport(ProgressBarUpdateEventArgs e) { if (e != null) { ProgressBarUpdate?.Invoke(this, e); } }
private void UpdateProgressBar(double value) { var t = (int)(value * 100); if (t > 100) { t = 100; } ProgressBarUpdate?.Invoke(t); }
public Form1() { InitializeComponent(); sync = new PlaylistSync(); PerformSyncCompleteImplementation = SyncCompleteButton; ProgressBarUpdateImplementation = UpdateProgressBar; PerformStatusUpdateImplementation = UpdateStatus; status.Text = "Ready"; MinimumSize = new Size(Width, Height); MaximumSize = new Size(Width, Height); }
/// <summary> /// 初始化拆分用预制体信息 /// </summary> /// <param name="iStaticOnly">仅处理静态物体</param> /// <param name="iDepthLimit">遍历深度限制 /// 备注: /// 小于0 不限制 /// 等于0 表示只访问root本身而不访问其子级, /// 大于0 正值表示最多访问的子级层数 /// </param> /// <param name="iUpdateProgress">进度更新委托</param> public void InitPrefabsInfo( bool iStaticOnly, int iDepthLimit = -1, ProgressBarUpdate iUpdateProgress = null) { if (null == Prefabs) { Prefabs = new List <GameObject>(); } Prefabs.Clear(); var roots = SceneManager.GetActiveScene().GetRootGameObjects(); if (null == roots || 0 >= roots.Length) { return; } // 遍历节点对象 foreach (var root in roots) { // 遍历 TraverseHierarchy(root, iStaticOnly, (iCurObj, iIsStaticOnly, iRetObj) => { // 若是地形对象,则返回继续遍历 if (iCurObj.GetComponent <Terrain>()) { return(null); } // 如果有MeshRender,或处理静态物体时, // 则认为是一个要处理的叶子节点,不再处理其孩子节点了 if ((iCurObj.GetComponent <MeshRenderer>() || iCurObj.GetComponent <Animator>() || iCurObj.GetComponent <LODGroup>()) && (false == iIsStaticOnly || iCurObj.isStatic)) { Prefabs.Add(iCurObj); return(iCurObj); } return(null); }, iDepthLimit); } if (null != iUpdateProgress) { iUpdateProgress("预制体拆分初始化", false); } Info("InitPrefabsInfo():StaticOnly:{0} Depth:{1}(Prefabs Count:{2})", iStaticOnly, iDepthLimit, (null == Prefabs) ? -1 : Prefabs.Count); }
public SoundcloudSyncMainForm() { InitializeComponent(); updateUtil = new UpdateUtils(); updateToolStripMenuItem.Text = updateUtil.LabelTextForCurrentStatus(); clientIdUtil = new ClientIDsUtils(); _apiConfigSettings = new API_Config(clientIdUtil); progressUtil = new ProgressUtils(); Text = $"SoundCloud Playlist Sync {Version()} Stable"; _performSyncCompleteImplementation = SyncCompleteButton; _progressBarUpdateImplementation = UpdateProgressBar; _performStatusUpdateImplementation = UpdateStatus; status.Text = @"Ready"; MinimumSize = new Size(Width, Height); MaximumSize = new Size(Width, Height); }
public SoundcloudSyncMainForm() { InitializeComponent(); updateUtil = new UpdateUtils(); updateToolStripMenuItem.Text = LanguageManager.Language["STR_MAIN_MENU_UPDATE"] + updateUtil.LabelTextForCurrentStatus(); clientIdUtil = new ClientIDsUtils(); _apiConfigSettings = new API_Config(clientIdUtil); progressUtil = new ProgressUtils(); Text = string.Format(LanguageManager.Language["STR_MAIN_TITLE_STABLE"], Version()); _performSyncCompleteImplementation = SyncCompleteButton; _progressBarUpdateImplementation = UpdateProgressBar; _performStatusUpdateImplementation = UpdateStatus; status.Tag = "STR_MAIN_STATUS_READY"; status.Text = LanguageManager.Language[status.Tag.ToString()]; MinimumSize = new Size(Width, Height); MaximumSize = new Size(Width, Height); }
/// <summary> /// 解析地形Tile数据 /// </summary> /// <param name="iSaveDir">保存目录</param> /// <param name="iTileIndex">Tile横向索引(Z轴方向)</param> /// <param name="iTerrainObj">拆分用地形对象</param> /// <param name="iMaxLayerLevel">地形最大层级</param> /// <param name="iLayerIndex">层级索引</param> /// <param name="iUpdateProgress">进度更新委托</param> public void SplitTerrains( string iSaveDir, GameObject iTerrainObj, Vector2 iTileIndex, int iMaxLayerLevel, int iLayerIndex, ProgressBarUpdate iUpdateProgress = null) { // 计算当前层级的拆分数量 var slicingCount = TerrainsSettings.CurSlicingCount(iMaxLayerLevel, iLayerIndex); // 计算当前层级Chunk尺寸计算 for (var r = 0; r < slicingCount; ++r) { for (var c = 0; c < slicingCount; ++c) { // 开始拆分 SplitTerrains( iSaveDir, iMaxLayerLevel - iLayerIndex, iTileIndex, slicingCount, iTerrainObj, new Vector2(r, c), iUpdateProgress); } } }
public SoundcloudSyncMainForm() { InitializeComponent(); updateUtil = new UpdateUtils(); clientIdUtil = new ClientIDsUtils(); _apiConfigSettings = new API_Config(clientIdUtil); progressUtil = new ProgressUtils(); LoadLanguagesInAllForms(int.Parse(SyncSetting.settings.Get("Language"))); Text = string.Format(LanguageManager.Language["STR_MAIN_TITLE_STABLE"], UpdateUtils.GetCurrentVersion()); _performSyncCompleteImplementation = SyncCompleteButton; _progressBarUpdateImplementation = UpdateProgressBar; _performStatusUpdateImplementation = UpdateStatus; status.Tag = "STR_MAIN_STATUS_READY"; status.Text = LanguageManager.Language[status.Tag.ToString()]; MinimumSize = new Size(Width, Height); MaximumSize = new Size(Width, Height); }
/// <summary> /// 拆分地形 /// </summary> /// <param name="iSaveDir">保存路径</param> /// <param name="iLayerLevel">地形层级</param> /// <param name="iTileIndex">地形的Tile索引</param> /// <param name="iSlicingCount">单个地形的拆分个数。(如:2x2 则为2)</param> /// <param name="iTerrainObj">地形对象</param> /// <param name="iChunkTileIndex">单个地形的拆分成chunk后的tile索引</param> /// <param name="iUpdateProgress">进度更新委托</param> private void SplitTerrains( string iSaveDir, int iLayerLevel, Vector2 iTileIndex, int iSlicingCount, GameObject iTerrainObj, Vector2 iChunkTileIndex, ProgressBarUpdate iUpdateProgress = null) { if (string.IsNullOrEmpty(iSaveDir)) { return; } if (0 >= iSlicingCount) { return; } if (null == iTerrainObj) { Error("SplitTerrains():The gameobject is null or invalid in hierarchy!!!"); return; } var terrain = iTerrainObj.GetComponent <Terrain>(); if (null == terrain) { Error("SplitTerrains():There is no component named terrain in the gameobject(name:{0})!!!", iTerrainObj.name); return; } // 地形数据 var terrainData = terrain.terrainData; // 地形尺寸 var terrainSize = terrainData.size; // 得到地图分辨率 var newHeightmapResolution = (terrainData.heightmapResolution - 1) / iSlicingCount; var newAlphamapResolution = terrainData.alphamapResolution / iSlicingCount; var newbaseMapResolution = terrainData.baseMapResolution / iSlicingCount; // 溅斑原型列表 var splatProtos = terrainData.splatPrototypes; var x = (int)iChunkTileIndex.x; var y = (int)iChunkTileIndex.y; //创建资源 // 地形拆分chunk保存路径 var morton = TerrainsSettings.Morton(iTileIndex, iChunkTileIndex, iSlicingCount, iLayerLevel); var chunkName = string.Format("{0}{1}.asset", TerrainsSettings.ChunkNamePrefix, morton); var savePath = string.Format("{0}/{1}", iSaveDir, chunkName); // 更新进度 - 拆分开始 if (null != iUpdateProgress) { var statusTxt = string.Format("拆分开始:{0}...", chunkName); iUpdateProgress(statusTxt, false); } var newData = new TerrainData(); if (null == newData) { Error("SplitTerrains():Failed!!(SavePath:{0})", savePath); return; } AssetDatabase.CreateAsset(newData, savePath); //设置分辨率参数 newData.heightmapResolution = newHeightmapResolution; newData.alphamapResolution = newAlphamapResolution; newData.baseMapResolution = newbaseMapResolution; //设置大小 newData.size = new Vector3(terrainSize.x / iSlicingCount, terrainSize.y, terrainSize.z / iSlicingCount); //设置地形原型 var newSplats = new SplatPrototype[splatProtos.Length]; for (var i = 0; i < splatProtos.Length; ++i) { newSplats[i] = new SplatPrototype { texture = splatProtos[i].texture, tileSize = splatProtos[i].tileSize }; var offsetX = (newData.size.x * x) % splatProtos[i].tileSize.x + splatProtos[i].tileOffset.x; var offsetY = (newData.size.z * y) % splatProtos[i].tileSize.y + splatProtos[i].tileOffset.y; newSplats[i].tileOffset = new Vector2(offsetX, offsetY); } newData.splatPrototypes = newSplats; //设置混合贴图 var alphamap = new float[newAlphamapResolution, newAlphamapResolution, splatProtos.Length]; alphamap = terrainData.GetAlphamaps( x * newData.alphamapWidth, y * newData.alphamapHeight, newData.alphamapWidth, newData.alphamapHeight); newData.SetAlphamaps(0, 0, alphamap); //设置高度 var xBase = (terrainData.heightmapWidth - 1) / iSlicingCount; var yBase = (terrainData.heightmapHeight - 1) / iSlicingCount; var height = terrainData.GetHeights(xBase * x, yBase * y, xBase + 1, yBase + 1); newData.SetHeights(0, 0, height); AssetDatabase.SaveAssets(); // 更新进度 - 拆分成功 if (null != iUpdateProgress) { var statusTxt = string.Format("拆分成功:{0}", chunkName); iUpdateProgress(statusTxt, true); } }