void OnGUI() { targetGo = (GameObject)EditorGUILayout.ObjectField(targetGo, typeof(GameObject), true); subPath = targetGo == null ? subPath : targetGo.name; EditorGUILayout.LabelField(string.Format("保存路径output path:{0}", Path.Combine(path, subPath))); path = EditorGUILayout.TextField(path); subPath = EditorGUILayout.TextField(subPath); stratege = (SaveStrategy)EditorGUILayout.EnumPopup("保存策略output type:", stratege); if (GUILayout.Button("Bake")) { if (targetGo == null) { EditorUtility.DisplayDialog("err", "targetGo is null!", "OK"); return; } if (baker == null) { baker = new AnimMapBaker(); } baker.SetAnimData(targetGo); List <BakedData> list = baker.Bake(); if (list != null) { for (int i = 0; i < list.Count; i++) { BakedData data = list[i]; Save(ref data); } } } }
public void Test_Update_InvalidEntityMustNotUpdate() { // Create the mock entity MockRequiredEntity entity = new MockRequiredEntity(); entity.TestProperty = "Test1"; entity.Validator = new ValidateStrategy(); // Save the entity SaveStrategy.New(entity, false).Save(entity); // Set the required property to empty entity.TestProperty = ""; Assert.IsFalse(entity.IsValid, "The validator returned true when it should return false."); // Update the invalid entity bool isValid = UpdateStrategy.New(entity, false).Update(entity); Assert.IsFalse(isValid, "The update strategy didn't recognise the entity as invalid."); MockRequiredEntity foundEntity = RetrieveStrategy.New <MockRequiredEntity>(false).Retrieve <MockRequiredEntity>("ID", entity.ID); Assert.IsNotNull(foundEntity); Assert.AreNotEqual(foundEntity.TestProperty, entity.TestProperty, "The entity was updated despite being invalid."); }
public sealed override void Deserialize(GenericReader reader) { int version = reader.ReadInt(); switch (version) { case 0: { this.m_SavesEnabled = reader.ReadBool(); this.m_SaveAccessLevel = (AccessLevel)reader.ReadByte(); this.m_SaveStrategy = Utilities.GetSaveStrategy((SaveStrategyTypes)reader.ReadByte()); this.m_AllowBackgroundWrite = reader.ReadBool(); this.m_SaveDelay = reader.ReadTimeSpan(); this.m_WarningDelays = new List <TimeSpan>(); int count = reader.ReadInt(); for (int i = 0; i < count; i++) { this.m_WarningDelays.Add(reader.ReadTimeSpan()); } this.m_NoIOHour = reader.ReadInt(); this.m_EnableEmergencyBackups = reader.ReadBool(); this.m_EmergencyBackupHour = reader.ReadInt(); this.m_CompressionLevel = (CompressionLevel)reader.ReadByte(); break; } } }
public void Test_Save_RemovesUnauthorisedReferences() { MockEntity entity = new MockEntity(); entity.ID = Guid.NewGuid(); MockRestrictedEntity restrictedEntity = new MockRestrictedEntity(); restrictedEntity.ID = Guid.NewGuid(); entity.RestrictedEntities = new MockRestrictedEntity[] { restrictedEntity }; SaveStrategy.New(restrictedEntity, false).Save(restrictedEntity); SaveStrategy.New(entity).Save(entity); MockEntity foundEntity = RetrieveStrategy.New <MockEntity>(false).Retrieve <MockEntity>("ID", entity.ID); Assert.IsNotNull(foundEntity); foundEntity.Activate(); Assert.AreEqual(0, foundEntity.RestrictedEntities.Length, "Restricted entity wasn't removed from reference property."); }
void OnGUI() { targetGo = (GameObject)EditorGUILayout.ObjectField(targetGo, typeof(GameObject), true); subPath = targetGo == null ? subPath : targetGo.name; EditorGUILayout.LabelField(string.Format("保存路径output path:{0}", Path.Combine(path, subPath))); //获得一个长300的框 Rect rect = EditorGUILayout.GetControlRect(GUILayout.Width(400)); //将上面的框作为文本输入框 path = EditorGUI.TextField(rect, path); subPath = EditorGUILayout.TextField(subPath); //如果鼠标正在拖拽中或拖拽结束时,并且鼠标所在位置在文本输入框内 if ((Event.current.type == EventType.DragUpdated || Event.current.type == EventType.DragExited) && rect.Contains(Event.current.mousePosition)) { //改变鼠标的外表 DragAndDrop.visualMode = DragAndDropVisualMode.Generic; if (DragAndDrop.paths != null && DragAndDrop.paths.Length > 0) { path = DragAndDrop.paths[0]; } } stratege = (SaveStrategy)EditorGUILayout.EnumPopup("保存策略output type:", stratege); if (stratege == SaveStrategy.Prefab || stratege == SaveStrategy.Mat) { targetMat = (Material)EditorGUILayout.ObjectField(targetMat, typeof(Material), true); } if (GUILayout.Button("Bake")) { if (targetGo == null) { EditorUtility.DisplayDialog("err", "targetGo is null, 请填第一个空!", "OK"); return; } if (baker == null) { baker = new AnimMapBaker(); } baker.SetAnimData(targetGo); List <BakedData> list = baker.Bake(); if (list != null) { for (int i = 0; i < list.Count; i++) { BakedData data = list[i]; Save(ref data); } } } }
private void OnGUI() { _targetGo = (GameObject)EditorGUILayout.ObjectField(_targetGo, typeof(GameObject), true); _subPath = _targetGo == null ? _subPath : _targetGo.name; EditorGUILayout.LabelField(string.Format($"Output Path: {Path.Combine(_path, _subPath)}")); _path = EditorGUILayout.TextField(_path); _subPath = EditorGUILayout.TextField(_subPath); _strategy = (SaveStrategy)EditorGUILayout.EnumPopup("Output Type:", _strategy); _isShadowEnabled = EditorGUILayout.Toggle("Enable Shadow", _isShadowEnabled); if (_isShadowEnabled) { var style = new GUIStyle(EditorStyles.label); style.normal.textColor = Color.yellow; EditorGUILayout.LabelField("Warning: Enabling shadows will cause additional draw calls to draw shadows.", style); _prevAnimMapShader = _animMapShader; _animMapShader = Shader.Find(ShadowShader); } else if (_prevAnimMapShader != null) { _animMapShader = _prevAnimMapShader; } if (!GUILayout.Button("Bake")) { return; } if (_targetGo == null) { EditorUtility.DisplayDialog("err", "targetGo is null!", "OK"); return; } if (_baker == null) { _baker = new AnimMapBaker(); } _baker.SetAnimData(_targetGo); var list = _baker.Bake(); if (list == null) { return; } foreach (var t in list) { var data = t; Save(ref data); } }
public virtual void Clear() { _items.Clear(); if (SaveStrategy.ShouldSaveNow()) { Save(); } OnItemsChanged(new List <T>()); }
public Solver(SolverState state, FilePath FilePath, SaveStrategy Save) { this.FilePath = FilePath; this.Save = Save; primeSum = state.primeSum; primeCounter = state.primeCounter; groupIndex = state.groupIndex; part = state.part; }
internal static void Postfix(FileSaveStrategy __result, string path, SaveStrategy type) { if (!string.IsNullOrEmpty(SessionData.Instance.SaveDirectory) || !path.ToLower().EndsWith("profile.save")) { return; } FileInfo fileInfo = new FileInfo(path); SessionData.Instance.SaveDirectory = fileInfo.Directory.FullName; SessionData.Instance.PlayerSaveStrategy = __result; }
public void Add(IEnumerable <T> items) { var list = items.ToList(); _items.AddRange(list); if (SaveStrategy.ShouldSaveNow()) { Save(); } OnItemsAdded(list); OnItemsChanged(list); }
public virtual void Add(T item) { _items.Add(item); if (SaveStrategy.ShouldSaveNow()) { Save(); } OnItemsAdded(new List <T> { item }); OnItemsChanged(new List <T> { item }); }
public void Test_Save() { TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>(); article.ID = Guid.NewGuid(); StrategyInfo info = StrategyState.Strategies["Save", "IEntity"]; ISaveStrategy strategy = SaveStrategy.New <TestArticle>(false); strategy.Save(article); TestArticle foundArticle = Data.DataAccess.Data.Reader.GetEntity <TestArticle>("ID", article.ID); Assert.IsNotNull(foundArticle); }
public void Test_Delete_Reorder() { using (LogGroup logGroup = LogGroup.StartDebug("Testing deletion of sub entities to ensure their position is updated.")) { TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>(); article.ID = Guid.NewGuid(); article.Title = "Test Article"; SaveStrategy.New(article, false).Save(article); Collection <TestArticlePage> pages = new Collection <TestArticlePage>(); // Create and save 3 article pages associated with the article for (int i = 0; i < 3; i++) { TestArticlePage page = CreateStrategy.New <TestArticlePage>(false).Create <TestArticlePage>(); page.Article = article; page.Title = "Page " + (i + 1); page.ID = Guid.NewGuid(); page.PageNumber = i + 1; pages.Add(page); SaveStrategy.New(page, false).Save(page); } // Delete the second page (0 based position = 1) DeleteStrategy.New(pages[1], false).Delete(pages[1]); // Load the article from the store TestArticle foundArticle = RetrieveStrategy.New <TestArticle>(false).Retrieve <TestArticle>("ID", article.ID); // Activate the pages on the article ActivateStrategy.New(foundArticle, false).Activate(foundArticle, "Pages"); Assert.IsNotNull(foundArticle.Pages, "Pages property isn't set."); Assert.AreEqual(2, foundArticle.Pages.Length, "Invalid number of pages."); foundArticle.Pages = Collection <TestArticlePage> .Sort(foundArticle.Pages, "PageNumberAscending"); Assert.AreEqual(1, foundArticle.Pages[0].PageNumber, "First page has wrong number."); Assert.AreEqual("Page 1", foundArticle.Pages[0].Title, "First page has wrong title."); Assert.AreEqual(2, foundArticle.Pages[1].PageNumber, "Third page has wrong number (should now be 2 as it's moved up one spot)."); Assert.AreEqual("Page 3", foundArticle.Pages[1].Title, "Third page has wrong title."); // Page 3 should now be at position 1 (ie. second place) } }
public SaveSettings(SaveStrategy saveStrategy, List <TimeSpan> warningDelays, TimeSpan saveDelay, bool savesEnabled = true, AccessLevel saveAccessLevel = AccessLevel.Administrator, bool allowBackgroundWrite = false, int noIOHour = -1, bool enableEmergencyBackups = true, int emergencyBackupHour = 3, CompressionLevel compressionLevel = CompressionLevel.Normal) { this.m_SavesEnabled = savesEnabled; this.m_SaveAccessLevel = saveAccessLevel; this.m_SaveStrategy = saveStrategy; this.m_AllowBackgroundWrite = allowBackgroundWrite; this.m_SaveDelay = saveDelay; this.m_WarningDelays = warningDelays; this.m_NoIOHour = noIOHour; this.m_EnableEmergencyBackups = enableEmergencyBackups; this.m_EmergencyBackupHour = emergencyBackupHour; this.m_CompressionLevel = compressionLevel; }
public virtual bool Remove(T item) { var removed = _items.Remove(item); if (SaveStrategy.ShouldSaveNow()) { Save(); } OnItemsRemoved(new List <T> { item }); OnItemsChanged(new List <T> { item }); return(removed); }
public void Test_Create_Parent() { MockProjection projection = new MockProjection(); projection.RequireAuthorisation = false; projection.Command = new CreateComandInfo(typeof(TestArticlePage).Name); TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>(); article.ID = Guid.NewGuid(); article.Title = "Test title"; SaveStrategy.New <TestArticle>(false).Save(article); CreateController controller = CreateController.New(projection); Assert.IsTrue(controller is CreateSubEntityController, "Invalid controller type: " + controller.GetType().ToString()); CreateSubEntityController createSubEntityController = (CreateSubEntityController)controller; ISubEntity subEntity = (ISubEntity)createSubEntityController.Create(article.ID, String.Empty); Assert.IsNotNull(subEntity, "No sub entity returned."); Assert.IsTrue((subEntity is TestArticlePage), "Wrong type returned: " + subEntity.GetType().ToString()); Assert.IsNotNull(subEntity.Parent, "No parent assigned to sub entity."); Assert.AreEqual(article.ID.ToString(), subEntity.Parent.ID.ToString(), "Parent ID doesn't match expected."); Assert.AreEqual(1, subEntity.Number, "Sub entity has wrong number."); SaveStrategy.New(subEntity, false).Save(subEntity); ISubEntity subEntity2 = (ISubEntity)createSubEntityController.Create(Guid.Empty, article.UniqueKey); Assert.IsNotNull(subEntity2, "No sub entity returned."); Assert.IsTrue((subEntity2 is TestArticlePage), "Wrong type returned: " + subEntity.GetType().ToString()); Assert.IsNotNull(subEntity2.Parent, "No parent assigned to sub entity."); Assert.AreEqual(article.ID.ToString(), subEntity2.Parent.ID.ToString(), "Parent ID doesn't match expected."); Assert.AreEqual(2, subEntity2.Number, "Sub entity has wrong number."); }
private void OnGUI() { _targetGo = (GameObject)EditorGUILayout.ObjectField(_targetGo, typeof(GameObject), true); _subPath = _targetGo == null ? _subPath : _targetGo.name; EditorGUILayout.LabelField(string.Format($"output path:{Path.Combine(_path, _subPath)}")); _path = EditorGUILayout.TextField(_path); _subPath = EditorGUILayout.TextField(_subPath); _stratege = (SaveStrategy)EditorGUILayout.EnumPopup("output type:", _stratege); if (GUILayout.Button("Bake")) { if (_targetGo == null) { EditorUtility.DisplayDialog("err", "targetGo is null!", "OK"); return; } if (_baker == null) { _baker = new AnimMapBaker(); } if (_animMapShader == null) { _animMapShader = Shader.Find("XHH/AnimMapShader"); } _baker.SetAnimData(_targetGo); var list = _baker.Bake(); if (list == null) { return; } foreach (var t in list) { var data = t; Save(ref data); } } }
public void Test_Update_AutoActivateReferences() { // Create the mock entities TestUser user = CreateStrategy.New <TestUser>(false).Create <TestUser>(); user.ID = Guid.NewGuid(); user.FirstName = "Test"; user.LastName = "User"; TestRole role = CreateStrategy.New <TestRole>(false).Create <TestRole>(); role.ID = Guid.NewGuid(); role.Name = "Test Role"; // Assign the user to the role user.Roles = new TestRole[] { role }; // Save the entities SaveStrategy.New(role, false).Save(role); SaveStrategy.New(user, false).Save(user); // Retrieve the mock user from the data store TestUser foundUser = RetrieveStrategy.New <TestUser>(false).Retrieve <TestUser>("ID", user.ID); // Change a standard property value foundUser.FirstName = "Test2"; // Update WITHOUT having activated the user manually // This update should automatically activate the user entity before updating and // should therefore persist the references UpdateStrategy.New(foundUser, false).Update(foundUser); // Retrieve the mock user again TestUser foundUser2 = RetrieveStrategy.New <TestUser>(false).Retrieve <TestUser>("ID", user.ID); // Manually activate the user foundUser2.Activate(); // Assert that the referenced roles are found on the user which indicates // that the update strategy did automatically activate the entity and persist // the references Assert.IsNotNull(foundUser2.Roles, "Roles property is null."); Assert.AreEqual(1, foundUser2.Roles.Length, "Invalid number of roles assigned to user."); }
public void Test_Create_FromParentID() { TestArticle article = CreateStrategy.New <TestArticle>(false).Create <TestArticle>(); article.ID = Guid.NewGuid(); article.Title = "Test Title"; SaveStrategy.New <TestArticle>(false).Save(article); CreateSubEntityStrategy strategy = (CreateSubEntityStrategy)CreateStrategy.New("TestArticlePage", false); TestArticlePage page = strategy.Create <TestArticlePage>(article.ID, String.Empty); Assert.IsNotNull(page.Article, "The article wasn't assigned to the page."); Assert.AreEqual(article.Title, page.Article.Title, "Article titles don't match."); Assert.AreEqual(1, page.PageNumber, "Invalid page number"); }
public virtual int Remove(IEnumerable <T> items) { var itemsToRemove = items.ToList(); var removedItems = new List <T>(); foreach (var item in itemsToRemove) { if (_items.Remove(item)) { removedItems.Add(item); } } if (SaveStrategy.ShouldSaveNow()) { Save(); } OnItemsRemoved(removedItems); OnItemsChanged(removedItems); return(removedItems.Count()); }
public void Test_Save_InvalidEntityMustNotSave() { // Create the mock entity MockInvalidEntity entity = new MockInvalidEntity(); entity.Validator = new ValidateStrategy(); Assert.IsFalse(entity.IsValid, "The validator returned true when it should return false."); // Try to save the entity bool isValid = SaveStrategy.New(entity, false).Save(entity); // Ensure that the save was rejected Assert.IsFalse(isValid, "The save strategy didn't recognise the entity as invalid."); // Try loading the entity from the data store to see if it's found MockInvalidEntity foundEntity = RetrieveStrategy.New <MockInvalidEntity>(false).Retrieve <MockInvalidEntity>("ID", entity.ID); // Ensure the entity wasn't found and therefore wasn't saved Assert.IsNull(foundEntity, "The entity was found in the store even though it shouldn't have saved."); }
public async virtual Task <int> UpdateAsync(T item) { var index = _items.IndexOf(item); if (index > -1) { _items.RemoveAt(index); _items.Insert(index, item); } if (SaveStrategy.ShouldSaveNow()) { await SaveAsync(); } OnItemsUpdated(new List <T> { item }); OnItemsChanged(new List <T> { item }); return(1); }
public async virtual Task <int> UpdateAsync(IEnumerable <T> items) { var itemsToUpdate = items.ToList(); foreach (var item in itemsToUpdate) { var index = _items.IndexOf(item); if (index > -1) { _items.RemoveAt(index); _items.Insert(index, item); } } if (SaveStrategy.ShouldSaveNow()) { await SaveAsync(); } OnItemsUpdated(itemsToUpdate); OnItemsChanged(itemsToUpdate); return(itemsToUpdate.Count()); }
public void Test_GetPostedEntities_AutoLoadPostEntitiesTrue() { TestRecord record = new TestRecord(); record.ID = Guid.NewGuid(); EntitySelect <TestRecord> ctrl = new EntitySelect <TestRecord>(); ctrl.AutoLoadPostEntities = true; ctrl.EntityType = record.GetType().FullName + ", " + typeof(TestRecord).Assembly.GetName().Name; ctrl.RequireAuthorisation = false; // Only false during testing Guid[] ids = new Guid[] { record.ID }; SaveStrategy.New(record, false).Save(record); IEntity[] entities = ctrl.GetPostedEntities(ids); Assert.IsNotNull(entities, "Returned null"); // The entity should have been loaded automatically Assert.AreEqual(1, entities.Length, "Invalid number of entities returned."); }
public void Test_GetPostedEntities_AutoLoadPostEntitiesFalse() { TestRecord record = new TestRecord(); record.ID = Guid.NewGuid(); EntitySelect <TestRecord> ctrl = new EntitySelect <TestRecord>(); ctrl.AutoLoadPostEntities = false; ctrl.EntityType = record.GetType().FullName + ", " + typeof(TestRecord).Assembly.GetName().Name; ctrl.RequireAuthorisation = false; // Only false during testing Guid[] ids = new Guid[] { record.ID }; SaveStrategy.New(record, false).Save(record); IEntity[] entities = ctrl.GetPostedEntities(ids); Assert.IsNotNull(entities, "Returned null"); // No entities should be returned because they weren't found on DataSource Assert.AreEqual(0, entities.Length, "Invalid number of entities returned."); }
public static SaveStrategyTypes GetSaveType(SaveStrategy saveStrategy) { if (saveStrategy is StandardSaveStrategy) { return(SaveStrategyTypes.StandardSaveStrategy); } else if (saveStrategy is DualSaveStrategy) { return(SaveStrategyTypes.StandardSaveStrategy); } else if (saveStrategy is DynamicSaveStrategy) { return(SaveStrategyTypes.DynamicSaveStrategy); } else if (saveStrategy is ParallelSaveStrategy) { return(SaveStrategyTypes.ParallelSaveStrategy); } else { return(SaveStrategyTypes.StandardSaveStrategy); } }
public void Test_Update_InactiveEntityCausesException() { // Create the mock entity TestUser user = CreateStrategy.New <TestUser>(false).Create <TestUser>(); user.ID = Guid.NewGuid(); user.FirstName = "Test"; user.LastName = "User"; // Save the entity SaveStrategy.New(user, false).Save(user); // Change a standard property value user.FirstName = "Test2"; // Set AutoActivate to false otherwise it'll auto activate and won't be tested properly user.AutoActivate = false; // Set IsActivated to false user.IsActivated = false; // Update the inactive entity UpdateStrategy.New(user, false).Update(user); }
private void OnGUI() { _targetGo = (GameObject)EditorGUILayout.ObjectField(_targetGo, typeof(GameObject), true); if (_oldTargetGo != _targetGo) { _oldTargetGo = _targetGo; ResetAll(); } _subPath = _targetGo == null ? _subPath : _targetGo.name; EditorGUILayout.HelpBox(string.Format($"Output Path : {Path.Combine(_path, _subPath)}"), MessageType.Info); _path = EditorGUILayout.TextField(_path); _subPath = EditorGUILayout.TextField(_subPath); _stratege = (SaveStrategy)EditorGUILayout.EnumPopup("output type:", _stratege); _multipleRows = EditorGUILayout.Toggle("Set VAT to multiple rows", _multipleRows); showTransform = EditorGUILayout.Foldout(showTransform, "Bake Transform"); if (showTransform) { EditorGUI.indentLevel += 2; _X = (Direction)EditorGUILayout.EnumPopup("Right", _X); _Y = (Direction)EditorGUILayout.EnumPopup("Up", _Y); _Z = (Direction)EditorGUILayout.EnumPopup("Forward", _Z); EditorGUI.indentLevel -= 2; } int[] xyz = new int[3]; SetXYZInfo(xyz, _X, _Y, _Z); int count = 0; int curClipFrame = 0; int bakedColume = 0; int bakedRow = 0; MessageType messageType = MessageType.Warning; if (_targetGo) { SkinnedMeshRenderer smr = _targetGo.GetComponentInChildren <SkinnedMeshRenderer>(); Animation anim = _targetGo.GetComponent <Animation>(); count = smr ? smr.sharedMesh.vertexCount : 0; if (anim != null) { List <AnimationState> _animClips = new List <AnimationState>(anim.Cast <AnimationState>()); curClipFrame = (int)(_animClips[0].clip.frameRate * _animClips[0].length); } bakedColume = Mathf.NextPowerOfTwo(count); bakedRow = Mathf.ClosestPowerOfTwo(curClipFrame); if (_multipleRows) { bakedColume = (int)Mathf.Log(Mathf.NextPowerOfTwo(count), 2); bakedRow = (int)Mathf.Log(Mathf.ClosestPowerOfTwo(curClipFrame), 2); int colHighOffset = (bakedColume - bakedRow) / 2; if (colHighOffset > 0) { bakedColume -= colHighOffset; bakedRow += colHighOffset; } bakedColume = (int)Mathf.Pow(2, bakedColume); bakedRow = (int)Mathf.Pow(2, bakedRow); } if (smr && anim) { messageType = MessageType.Info; } } bool clickBakeBTN = !GUILayout.Button("Bake"); string smrS = count != 0 ? $"Vertex Count : {count}" : "SkinnedMeshRenderer Missing"; string aniS = curClipFrame != 0 ? $"Animation Frame Count : {curClipFrame}" : "Animation Missing"; EditorGUILayout.HelpBox(string.Format($"{smrS}\n{aniS}" + $"\nBaked Texture Output Size : {bakedColume} x {bakedRow}"), messageType); EditorGUILayout.Space(10); showAdvanced = EditorGUILayout.Foldout(showAdvanced, "Advanced"); if (showAdvanced) { EditorGUI.indentLevel += 2; _shader = EditorGUILayout.TextField("Shader Find", _shader); EditorGUI.indentLevel -= 2; } if (clickBakeBTN) { return; } if (_targetGo == null) { EditorUtility.DisplayDialog("err", "targetGo is null!", "OK"); return; } if (_baker == null) { _baker = new AnimMapBaker(); } _baker.SetAnimData(_targetGo, _multipleRows, xyz); EditorUtility.DisplayProgressBar("Bake Animation Texture", "baking...", 0.5f); List <BakedData> list = _baker.Bake(); EditorUtility.DisplayProgressBar("Bake Animation Texture", "saving...", 0.8f); if (list == null) { return; } foreach (var t in list) { var data = t; Save(ref data); } EditorUtility.DisplayProgressBar("Bake Animation Texture", "complete...", 0.99f); EditorUtility.ClearProgressBar(); }
void OnGUI() { if (animMapShader == null) { animMapShader = Shader.Find("chenjd/AnimMapShader"); } if (obj != null && objIndex < obj.Length) { targetGo = obj[objIndex] as GameObject; } targetGo = (GameObject)EditorGUILayout.ObjectField(targetGo, typeof(GameObject), true); subPath = targetGo == null ? subPath : targetGo.name; EditorGUILayout.LabelField(string.Format("保存路径output path:{0}", Path.Combine(path, subPath))); path = EditorGUILayout.TextField(path); subPath = EditorGUILayout.TextField(subPath); stratege = (SaveStrategy)EditorGUILayout.EnumPopup("保存策略output type:", stratege); if (baking || GUILayout.Button("Bake")) { if (!AssetDatabase.IsValidFolder("Assets/" + path)) { AssetDatabase.CreateFolder("Assets", path); } if (obj != null) { baking = (objIndex < obj.Length); if (!baking) { obj = null; targetGo = null; editorWindow.Close(); EditorUtility.DisplayDialog("", "批量处理结束", "OK"); return; } } if (targetGo == null) { editorWindow.Close(); EditorUtility.DisplayDialog("err", "targetGo is null!", "OK"); return; } if (baker == null) { baker = new AnimMapBaker(); } baker.SetAnimData(targetGo); List <BakedData> list = baker.Bake(); if (list != null) { for (int i = 0; i < list.Count; i++) { BakedData data = list[i]; Save(ref data); } } objIndex += 1; } }