/// <summary> /// 挂载武器 /// </summary> /// <param name="weaponStr"></param> void DOMountWeapon(string weaponStr) { if (!IsInBattle) { return; } UnMountCurrentWeapon(); if (string.IsNullOrEmpty(weaponStr)) { return; } var paras = weaponStr.Split('|'); int index = 0; string prefab = paras[index++]; string bindObj = paras[index++]; float scale = float.Parse(paras[index++]); Vector3 pos = UnityTools.StringToVector3(paras[index++], ','); Vector3 rot = UnityTools.StringToVector3(paras[index++], ','); Jyx2ResourceHelper.SpawnPrefab(prefab, weaponObj => { m_CurrentWeapon = weaponObj; var parent = UnityTools.DeepFindChild(transform, bindObj); if (parent != null) { weaponObj.transform.SetParent(parent.transform); weaponObj.transform.localScale = new Vector3(scale, scale, scale); weaponObj.transform.localPosition = pos; weaponObj.transform.localRotation = Quaternion.Euler(rot); } else { Debug.LogError("武器挂载到了不存在的节点:" + bindObj); } }); }