#Resources.Load
1 messages · Page 1 of 1 (latest)
Ill send you that in a couple of hours
so : here is the code
public void SpawnWeapon(NetworkVariable<int> weaponSpawn)
{
weapon = Resources.Load<SO_Weapons>("Assets/Resources/ScriptableObject/Player/Weapons/W_" + weaponSpawn.Value + ".asset");
//weapon = AssetDatabase.LoadAssetAtPath<SO_Weapons>("Assets/Resources/ScriptableObject/Player/Weapons/W_" + weaponSpawn.Value + ".asset");
PlayerController playerController = GetComponent<PlayerController>();
if (Resources.Load<SO_Weapons>("Assets/Resources/ScriptableObject/Player/Weapons/W_0.asset") == null) playerController.playerWeapon.text = "No weapon";
if (weaponSpawner.transform.childCount > 0) Destroy(weaponSpawner.transform.GetChild(0).gameObject);
Instantiate(weapon.weaponPrefab, weaponSpawner.transform.position, new Quaternion(0, 0, 0, 0), weaponSpawner.transform);
}```
here is mu file path : "Assets/Resources/ScriptableObject/Player/Weapons/W_0.asset"
Take out the "Assets/Resources/" in the path there. It should start with ScriptableObject
well still not having it loaded
public void SpawnWeapon(NetworkVariable<int> weaponSpawn)
{
weapon = Resources.Load<SO_Weapons>("ScriptableObject/Player/Weapons/W_0.asset");
//weapon = AssetDatabase.LoadAssetAtPath<SO_Weapons>("Assets/Resources/ScriptableObject/Player/Weapons/W_" + weaponSpawn.Value + ".asset");
PlayerController playerController = GetComponent<PlayerController>();
if (Resources.Load<SO_Weapons>("ScriptableObject/Player/Weapons/W_0.asset") == null) playerController.playerWeapon.text = "No weapon";
if (weaponSpawner.transform.childCount > 0) Destroy(weaponSpawner.transform.GetChild(0).gameObject);
Instantiate(weapon.weaponPrefab, weaponSpawner.transform.position, new Quaternion(0, 0, 0, 0), weaponSpawner.transform);
}
i removed the asset/resources but when i'm at my if Resources.Load... == Null i still gave no weapon
i'm trying if i put the asset directly in the resources folder and not in a subfolder
well still not working
is it due to my scriptableobject ?