You've already forked UniversalViewer
							
							DanMachi:
-compatibility improvements Core: -simplified object and keyframe serialization -complicated assetbundle loading
This commit is contained in:
		| @@ -60,32 +60,33 @@ public class CharacterDropdown : MonoBehaviour | ||||
|  | ||||
|         UnityAction<int> groupCallback = (index) => | ||||
|         { | ||||
|             if (index == 0) return; | ||||
|             if (index == 0) | ||||
|             { | ||||
|                 SetDropdownData(1, null); | ||||
|                 Despawn(); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var category = GetOption(0); | ||||
|             SetDropdownData(1, characters.Where(c => c.Category == category).Select(c => c.Id).Distinct().ToList(), true, true); | ||||
|             //SetDropdownData(2, new List<string>(), true, true); | ||||
|         }; | ||||
|  | ||||
|         UnityAction<int> charaCallback = (index) => | ||||
|         { | ||||
|             if (index == 0) return; | ||||
|             if (index == 0) | ||||
|             { | ||||
|                 Despawn(); | ||||
|                 return; | ||||
|             } | ||||
|  | ||||
|             var category = GetOption(0); | ||||
|             var id = GetOption(1); | ||||
|             var costumes = characters.Where(c => c.Category == category && c.Id == id); | ||||
|             var costume = costumes.FirstOrDefault(c => c.Costume == "common"); | ||||
|             costume ??= costumes.First(); | ||||
|             DanMachiModelBuilder.Instance.SpawnCharacter(costume); | ||||
|             //SetDropdownData(2, characters.Where(c => c.Category == category && c.Id == id).Select(c => c.Costume).ToList(), true, true); | ||||
|             DanMachiModelBuilder.Instance.SpawnAsset(AssetTypes.Character, costume.AssetName); | ||||
|         }; | ||||
|  | ||||
|         //UnityAction<int> costumeCallback = (index) => | ||||
|         //{ | ||||
|         //    var chara = DanMachiAssetLibrary.Instance.GetCharacter(GetOption(0), GetOption(1), GetOption(2)); | ||||
|         //    StartCoroutine(DanMachiModelBuilder.Instance.SpawnAsset(AssetTypes.Character, chara)); | ||||
|         //}; | ||||
|  | ||||
|         SetCallbacks(new List<UnityAction<int>>() | ||||
|         { | ||||
|             groupCallback, | ||||
| @@ -113,7 +114,7 @@ public class CharacterDropdown : MonoBehaviour | ||||
|         { | ||||
|             Debug.LogError("Delete Current"); | ||||
|         } | ||||
|         StartCoroutine(ModelBuilder.GetInstance().SpawnAsset(AssetTypes.Character, MainDropdown.options[selection].text)); | ||||
|         StartCoroutine(ModelBuilder.GetInstance().SpawnAssetCoroutine(AssetTypes.Character, MainDropdown.options[selection].text)); | ||||
|     } | ||||
|  | ||||
|     public void SetDropdownData(string label, List<string> options, bool nullValue = false, bool sortValues = false) | ||||
| @@ -122,12 +123,6 @@ public class CharacterDropdown : MonoBehaviour | ||||
|         SetDropdownData(depth, options, nullValue, sortValues); | ||||
|     } | ||||
|  | ||||
|     public string GetOption(int depth) | ||||
|     { | ||||
|         if (Dropdowns[depth].value == 0) return null; | ||||
|         return Dropdowns[depth].options[Dropdowns[depth].value].text; | ||||
|     } | ||||
|  | ||||
|     public void SetDropdownData(int depth, List<string> options, bool nullValue = false, bool sortValues = false) | ||||
|     { | ||||
|         if (depth >= Dropdowns.Count || depth < 0) | ||||
| @@ -137,4 +132,42 @@ public class CharacterDropdown : MonoBehaviour | ||||
|         } | ||||
|         ModelViewerInterface.SetDropdownData(Dropdowns[depth], options, nullValue, sortValues); | ||||
|     } | ||||
|  | ||||
|     public void SelectDropdownData(int depth, string valueText, bool notify) | ||||
|     { | ||||
|         var dropdown = Dropdowns[depth]; | ||||
|         var value = dropdown.options.FindIndex(d=>d.text == valueText); | ||||
|         SelectDropdownData(depth, value, notify); | ||||
|     } | ||||
|  | ||||
|     public void SelectDropdownData(int depth, int value, bool notify) | ||||
|     { | ||||
|         if (value == -1) return; | ||||
|  | ||||
|         var dropdown = Dropdowns[depth]; | ||||
|  | ||||
|         if (notify) | ||||
|         { | ||||
|             dropdown.value = value; | ||||
|         } | ||||
|         else | ||||
|         { | ||||
|             dropdown.SetValueWithoutNotify(value); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     public string GetOption(int depth) | ||||
|     { | ||||
|         if (Dropdowns[depth].value == 0) return null; | ||||
|         return Dropdowns[depth].options[Dropdowns[depth].value].text; | ||||
|     } | ||||
|  | ||||
|     private void Despawn() | ||||
|     { | ||||
|         var selected = ModelViewerMain.GetInstance().SelectedObject; | ||||
|         if (selected != null) | ||||
|         { | ||||
|             selected.Destroy(); | ||||
|         } | ||||
|     } | ||||
| } | ||||
|   | ||||
| @@ -28,9 +28,10 @@ public class CharacterPanel : MonoBehaviour | ||||
|     { | ||||
|         var pose = _selectedChara.SerializeFrame(); | ||||
|         var data = _selectedChara.Data; | ||||
|         var newData = DanMachiAssetLibrary.Instance.Characters.First(c => c.Category == data.Category && c.Id == data.Id && c.Costume == CostumeDropdown.options[value].text); | ||||
|         var chara = DanMachiModelBuilder.Instance.SpawnCharacter(newData); | ||||
|         chara.PastePose(pose, PoseLoadOptions.All()); | ||||
|         _selectedChara.Rebuild(DanMachiAssetLibrary.Instance.Characters.First(c => c.Category == data.Category && c.Id == data.Id && c.Costume == CostumeDropdown.options[value].text)); | ||||
|         //var newData = DanMachiAssetLibrary.Instance.Characters.First(c => c.Category == data.Category && c.Id == data.Id && c.Costume == CostumeDropdown.options[value].text); | ||||
|         //var chara = DanMachiModelBuilder.Instance.SpawnAsset(AssetTypes.Character, newData.AssetName); | ||||
|         _selectedChara.PastePose(pose, PoseLoadOptions.All()); | ||||
|     } | ||||
|  | ||||
|     public void SelectAnimationSet(int value) | ||||
| @@ -38,6 +39,7 @@ public class CharacterPanel : MonoBehaviour | ||||
|         if(value == 0) | ||||
|         { | ||||
|             AnimationDropdown.SetOptions(null); | ||||
|             _selectedChara.PlayAnimation((AnimationClip)null); | ||||
|             return; | ||||
|         } | ||||
|         var data = _selectedChara.Data; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user