mirror of
https://github.com/GTA-ASM/SanAndreasUnity
synced 2025-02-17 05:18:27 +00:00
create weapon from prefab
This commit is contained in:
parent
a85e337ae6
commit
df12bf2b65
2 changed files with 8 additions and 4 deletions
|
@ -161,7 +161,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
WeaponDef def;
|
||||
WeaponData weaponData;
|
||||
GameObject go = CreatePart1(modelId, out def, out weaponData);
|
||||
GameObject go = CreatePart1(modelId, null, out def, out weaponData);
|
||||
if (null == go)
|
||||
return null;
|
||||
|
||||
|
@ -181,7 +181,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
return weapon;
|
||||
}
|
||||
|
||||
static GameObject CreatePart1(int modelId, out WeaponDef def, out WeaponData weaponData)
|
||||
static GameObject CreatePart1(int modelId, GameObject go, out WeaponDef def, out WeaponData weaponData)
|
||||
{
|
||||
def = null;
|
||||
weaponData = null;
|
||||
|
@ -204,7 +204,9 @@ namespace SanAndreasUnity.Behaviours
|
|||
// weaponsContainer.SetActive (false);
|
||||
}
|
||||
|
||||
GameObject go = new GameObject (def.ModelName);
|
||||
if (null == go)
|
||||
go = Object.Instantiate(WeaponsManager.Instance.weaponPrefab);
|
||||
go.name = def.ModelName;
|
||||
go.transform.SetParent (s_weaponsContainer.transform);
|
||||
|
||||
geoms.AttachFrames (go.transform, MaterialFlags.Default);
|
||||
|
@ -255,7 +257,7 @@ namespace SanAndreasUnity.Behaviours
|
|||
|
||||
WeaponDef def;
|
||||
WeaponData weaponData;
|
||||
GameObject go = CreatePart1(networkedWeapon.ModelId, out def, out weaponData);
|
||||
GameObject go = CreatePart1(networkedWeapon.ModelId, networkedWeapon.gameObject, out def, out weaponData);
|
||||
if (null == go)
|
||||
return;
|
||||
|
||||
|
|
|
@ -6,6 +6,8 @@ namespace SanAndreasUnity.Behaviours.Weapons
|
|||
|
||||
public class WeaponsManager : MonoBehaviour {
|
||||
|
||||
public GameObject weaponPrefab;
|
||||
|
||||
[SerializeField] [Range(2.5f, 4.5f)] private float m_animConvertMultiplier = 3.5f;
|
||||
public float AnimConvertMultiplier { get { return m_animConvertMultiplier; } set { m_animConvertMultiplier = value; } }
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue