Can someone help me achieve the correct code I need in order to test my prefab:
Unity Version: 2018.1.0f2
Load a prefab from disc somehow that isn’t using Resources.Load.
Create an instance of the prefab (I imagine once I have the correct code to load the thing its a simple GameObject.Instantiate() call but i am likely to be wrong)
I want to be able to instantiate a prefab in a play mode test in c# code so that I can attempt testing my class. I thought this would be trivial to do so, I am finding that it is not. Reading best practices had advised me not to use Resources.Load ( Assets, Resources and AssetBundles - Unity Learn ‘Don’t Use it.’) and that I should use this asset bundle “thing” that I am having some difficulty using for my test.
This is as close as I have gotten which needless to say, is not close at all:
the assetBundles variable contains a list with one entry. “game” (now two “game.game”)
the paths variable contains a list with one entry “Assets/Spessman/Resources/Prefabs/Player.prefab” which is the correct asset I want, but I do not know how to load it so that I can instantiate based off it, which I am guessing what I need to do.
The error I am getting is:
WhenCreatingAnActorController (0.000s)
— OneTimeSetUp: Unhandled log message: ‘[Error] Unable to read
header from archive file:
Assets/Spessman/Resources/Prefabs/Player.prefab’.
Use
UnityEngine.TestTools.LogAssert.Expect
which I imagine is because I am meant to point at an Asset Bundle file and not a thing i want to load (guessing completely)
From some part of my mucking around I have magically conjured another of these “asset bundles” that i can’t seem to find anywhere in the project called game.game that is erroneous.
Thank you for your time.