public void Reset() { if (TempGameObject != null) { GameObject.DestroyImmediate(TempGameObject); } AttachmentPair = null; }
public void ChangeAttachment(string partName, string sourceName) { AttachmentPair ap = new AttachmentPair(); ap.partName = partName; ap.sourceName = sourceName; ChangeAttachment(ap); ApplyAttachments(); }
public void ChangeAttachment(string partName, string sourceName, bool isUpdate = true) { AttachmentPair ap = new AttachmentPair(); ap.partName = partName; ap.sourceName = sourceName; ChangeAttachment(ap); if (isUpdate) { Debug.Log("暂时没有实现"); } }
public void CreateInitialState(string name) { if (AttachmentPair != null) { Debug.LogError("Attachment pair already created. Make sure to clean any previous state before initializing a new one.", AttachmentPair); return; } TempGameObject = new GameObject(); TempGameObject.hideFlags = HideFlags.HideAndDontSave; AttachmentPair = AttachmentPair.Create(TempGameObject); Name = Factory.CreateName(name + "_constraint"); }
private void ChangeAttachment(AttachmentPair part) { BodyPart bp = new BodyPart(); GameObject partObject = SceneManager.LoadPrefab <GameObject>(part.sourceName); SkinnedMeshRenderer[] smrs = partObject.GetComponentsInChildren <SkinnedMeshRenderer>(true); for (int i = 0; i < smrs.Length; i++) { SkinnedMeshRenderer sm = smrs[i]; //骨骼 for (int b = 0; b < sm.bones.Length; b++) { string boneName = sm.bones[b].name; Transform bone = GetBone(boneName); if (bone) { bp.bones.Add(bone); } else { Debug.LogError(part.partName + "部位,切换装备:" + part.sourceName + "没有找到" + boneName + "骨骼"); } } //mesh for (int s = 0; s < sm.sharedMesh.subMeshCount; s++) { CombineInstance ci = new CombineInstance(); ci.mesh = sm.sharedMesh; ci.subMeshIndex = s; bp.combines.Add(ci); } //mat for (int m = 0; m < sm.sharedMaterials.Length; m++) { bp.mats.Add(sm.sharedMaterials[m]); } } mParts[part.partName] = bp; }
public ConstraintAttachmentFrameTool(AttachmentPair attachmentPair, UnityEngine.Object onChangeDirtyTarget = null) { AttachmentPair = attachmentPair; OnChangeDirtyTarget = onChangeDirtyTarget; }
private void ChangeAttachment(AttachmentPair part) { }