public void WearItem(Item item) { if (item.type == Item.ItemType.Fish || item.type == Item.ItemType.None) { return; } if (item.type == Item.ItemType.Shoe) { Instance.nvAgent.speed = item.data.movementSpeed; } var sameItems = Equipment.Where(x => x.type == item.type); if (sameItems.Count() > 0) { UnwearItem(sameItems.ElementAt(0)); } Equipment.Add(item); if (item.type == Item.ItemType.Rod) { return; } foreach (var child in item.transform.GetComponentsInChildren <Transform>()) { child.gameObject.layer = LayerMask.NameToLayer("Player"); } var reassignWeights = item.rendererGameObject.GetComponent <ReassignBoneWeigthsToNewMesh>(); item.transform.position = transform.position; item.rendererGameObject.transform.parent = transform; if (smCombiner.isMeshesCombined()) { smCombiner.UndoCombineMeshes(true, true); } reassignWeights.newArmature = Instance.armature; reassignWeights.rootBoneName = "Spine1"; reassignWeights.Reassign(); smCombiner.CombineMeshes(); }
private IEnumerator OptimizeAppearance(Action afterUndo) { yield return(new WaitForSeconds(0.1f)); int meshLayer = -1; var cm = GetCombinedMesh(); if (cm) { meshLayer = meshCombiner.gameObject.layer; meshCombiner.UndoCombineMeshes(); } afterUndo?.Invoke(); yield return(new WaitForFixedUpdate()); meshCombiner.meshesToIgnore.Clear(); var petControllers = gameObject.transform.GetComponentsInChildren <PetController>(); foreach (var pet in petControllers) { var renderer = pet.GetComponentInChildren <SkinnedMeshRenderer>(); if (renderer && renderer.sharedMesh) { meshCombiner.meshesToIgnore.Add(renderer); } } yield return(new WaitForFixedUpdate()); meshCombiner.CombineMeshes(); gameManager.Camera.EnsureObserverCamera(); }
public void Optimize(Action afterUndo = null) { int meshLayer = -1; if (transform.Find("Combined Mesh")) { meshLayer = meshCombiner.gameObject.layer; meshCombiner.UndoCombineMeshes(); } afterUndo?.Invoke(); meshCombiner.meshesToIgnore.Clear(); var petControllers = gameObject.transform.GetComponentsInChildren <PetController>(); foreach (var pet in petControllers) { var renderer = pet.GetComponentInChildren <SkinnedMeshRenderer>(); if (renderer && renderer.sharedMesh) { meshCombiner.meshesToIgnore.Add(renderer); } } meshCombiner.CombineMeshes(); gameManager.Camera.EnsureObserverCamera(); }
public virtual void UpdateUMAMesh(bool updatedAtlas) { combinedMeshList = new List <SkinnedMeshCombiner.CombineInstance>(); combinedMaterialList = new List <Material>(); if (updatedAtlas) { CombineByShader(); } else { CombineByMaterial(); } if (umaData.firstBake) { umaData.myRenderer.sharedMesh = new Mesh(); // umaData.TMPmyRenderer = Instantiate (umaData.myRenderer) as SkinnedMeshRenderer; // umaData.TMPmyRenderer.sharedMesh = new Mesh(); } var boneMap = new Dictionary <Transform, Transform>(); SkinnedMeshCombiner.CombineMeshes(umaData.myRenderer, combinedMeshList.ToArray(), boneMap); // SkinnedMeshCombiner.CombineMeshes(umaData.TMPmyRenderer, combinedMeshList.ToArray(), boneMap); if (updatedAtlas) { RecalculateUV(); } umaData.umaRecipe.ClearDNAConverters(); for (int i = 0; i < umaData.umaRecipe.slotDataList.Length; i++) { DKSlotData slotData = umaData.umaRecipe.slotDataList[i]; if (slotData != null) { umaData.EnsureBoneData(slotData.umaBoneData, boneMap); umaData.umaRecipe.AddDNAUpdater(slotData.slotDNA); } } umaData.myRenderer.quality = SkinQuality.Bone4; // umaData.TMPmyRenderer.quality = SkinQuality.Bone4; umaData.myRenderer.useLightProbes = true; // umaData.TMPmyRenderer.useLightProbes = true; umaData.myRenderer.sharedMaterials = combinedMaterialList.ToArray(); // umaData.TMPmyRenderer.sharedMaterials = combinedMaterialList.ToArray(); //umaData.myRenderer.sharedMesh.RecalculateBounds(); umaData.myRenderer.sharedMesh.name = "UMAMesh"; // umaData.TMPmyRenderer.sharedMesh.name = "UMAMesh"; umaData.firstBake = false; }
public void ButtonM() { //Example of API to merge and undo merge if (charM.isMeshesCombined() == true) { charM.UndoCombineMeshes(true, true); } else { charM.CombineMeshes(); } }
public void MeRg() { if (_Combiner.isMeshesCombined()) { Stopwatch watch = Stopwatch.StartNew(); _Combiner.UndoCombineMeshes(true, false); Debug.Log("Uncombining took: " + watch.ElapsedMilliseconds); } else { Stopwatch watch = Stopwatch.StartNew(); _Combiner.CombineMeshes(); Debug.Log("combining took: " + watch.ElapsedMilliseconds); } }
public void Optimize(Action afterUndo = null) { if (!meshCombiner || !this.gameObject.activeInHierarchy || !this.gameObject.activeSelf) { return; } int meshLayer = -1; if (transform.Find("Combined Mesh")) { meshCombiner.UndoCombineMeshes(); } afterUndo?.Invoke(); meshCombiner.meshesToIgnore.Clear(); meshCombiner.CombineMeshes(); }
public void Optimize(Action afterUndo = null) { //this.gameObject.CombineMeshes(); int meshLayer = -1; if (transform.Find("Combined Mesh")) { meshLayer = meshCombiner.gameObject.layer; meshCombiner.UndoCombineMeshes(); } afterUndo?.Invoke(); meshCombiner.meshesToIgnore.Clear(); var petControllers = gameObject.transform.GetComponentsInChildren <PetController>(); foreach (var pet in petControllers) { var renderer = pet.GetComponentInChildren <SkinnedMeshRenderer>(); if (renderer && renderer.sharedMesh) { meshCombiner.meshesToIgnore.Add(renderer); } } meshCombiner.CombineMeshes(); if (meshLayer == -1) { return; } var combinedMesh = transform.Find("Combined Mesh"); if (!combinedMesh) { return; } combinedMesh.gameObject.layer = meshLayer; }