void UnequipAll() { for (int i = 0; i < currentEquipment.Length; i++) { oldItem = currentEquipment[i]; Inventory.instance.ReplaceItems(null, oldItem); currentEquipment[i] = null; equipmentSlot[i].icon.sprite = null; equipmentSlot[i].icon.enabled = false; Destroy(currentMeshes[i]); onEquipmentChanged.Invoke(null, oldItem); } if (UIController.instance.chestMode == true) { UIController.instance.onUpdateUICallback.Invoke(); } SkinnedMeshRenderer[] equippedItems = targetMesh.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int i = 1; i < equippedItems.Length; i++) { Destroy(equippedItems[i].gameObject); } // Малко тъпо решение, но работи, тъй като винаги Body (parent-a на equip-натите item-и) е с индекс 0. // Затова го пропускаме, като започваме директно от обекта на индекс 1. (i = 1) }
public virtual void onDeadEnd()//替换死亡后的材质 { if (m_MonBody != null) { SkinnedMeshRenderer[] curSMRs = m_MonBody.GetComponentsInChildren <SkinnedMeshRenderer>(); for (int i = 0; i < curSMRs.Length; i++) { Material mtl_inst = GameObject.Instantiate(gameST.DEAD_MTL) as Material; Texture tex = curSMRs[i].material.GetTexture(gameST.MTL_Main_Tex); mtl_inst.SetTexture(gameST.MTL_Dead_Tex, tex); curSMRs[i].material = mtl_inst; } m_bchangeDeadMtl = true; } }
public void OnSceneGUI(SceneView sceneView) { if (skin != null && isPainting) { HandleUtility.AddDefaultControl(GUIUtility.GetControlID(FocusType.Passive)); Mesh m = skin.sharedMesh.Clone(); m.colors = CalculateVertexColors(skin.bones, m, skin.bones[bone].GetComponent <Bone>()); List <BoneWeight> weights = m.boneWeights.ToList(); Event current = Event.current; Graphics.DrawMeshNow(m, skin.transform.position, skin.transform.rotation); Bone bn = skin.bones[bone].GetComponent <Bone>(); foreach (Bone b in skin.GetComponentsInChildren <Bone>()) { if (bn == b) { Handles.color = Color.yellow; } else { Handles.color = Color.gray; } Handles.DrawLine(b.transform.position, b.Head); } Handles.color = Color.red; Vector3 mpos = HandleUtility.GUIPointToWorldRay(current.mousePosition).origin; mpos = new Vector3(mpos.x, mpos.y); Handles.DrawWireDisc(mpos, Vector3.forward, brushSize); if (isPainting) { if (current.type == EventType.scrollWheel && current.modifiers == EventModifiers.Control) { brushSize = Mathf.Clamp(brushSize + (float)System.Math.Round(current.delta.y / 30, 2), 0, float.MaxValue); Repaint(); current.Use(); } else if (current.type == EventType.mouseDown && current.button == 0) { isDrawing = true; } else if (current.type == EventType.mouseUp && current.button == 0) { isDrawing = false; } else if (current.type == EventType.mouseDrag && isDrawing && current.button == 0) { float w = weight * ((mode == PaintingMode.Subtract) ? -1 : 1); for (int i = 0; i < m.vertices.Length; i++) { Vector3 v = m.vertices[i]; float d = (v - skin.gameObject.transform.InverseTransformPoint(mpos)).magnitude; if (d <= brushSize) { BoneWeight bw = weights[i]; float vw = bw.GetWeight(bn.index); vw = Mathf.Clamp(vw + (1 - d / brushSize) * w, 0, 1); bw = bw.SetWeight(bn.index, vw); weights[i] = bw.Clone(); } } skin.sharedMesh.boneWeights = weights.ToArray(); EditorUtility.SetDirty(skin.gameObject); if (PrefabUtility.GetPrefabType(skin.gameObject) != PrefabType.None) { AssetDatabase.SaveAssets(); } } } sceneView.Repaint(); } }