Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
Tags

[SOLVED!] ArgumentException: The Object you want to instantiate is null.

A topic by bryantdrewjones created Jan 19, 2017 Views: 5,529 Replies: 5
Viewing posts 1 to 5
(1 edit)

Hey there :) I'm trying to create a new Super Text UI object from the GameObject >> UI menu, and I'm getting the following error:

ArgumentException: The Object you want to instantiate is null.
UnityEngine.Object.CheckNullArgument (System.Object arg, System.String message) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:196)
UnityEngine.Object.Instantiate[GameObject] (UnityEngine.GameObject original) (at /Users/builduser/buildslave/unity/build/Runtime/Export/UnityEngineObject.cs:188)
SuperTextMesh.MakeNewUIText (UnityEditor.MenuCommand menuCommand) (at Assets/Tools/SuperTextMesh/Clavian/SuperTextMesh/Scripts/SuperTextMesh.cs:475)

I tool a look at SuperTextMesh.cs:475 and it's expecting the Super Text.prefab to be at a hardcoded position in my Assets directory. I have all of my Asset Store assets in a sub-folder in my project to keep things clean. Can we maybe/hopefully ask the tool to find itself in the project rather than hardcoding the path? I can easily workaround this issue for now by changing the path in the code, but then I'll have to do that again with each new update :-/

Developer

Hey!

Everything was meant to be left in that specific folder, but you can also create a new UI text by doing this:

  • Create a new child object under a canvas
  • add a Super Text Mesh component to it
  • it'll become the same as the prefab, without needing the prefab!
That said, I'll try to add relative folders for the next update! I can see why users would want to organize folders like that. I should be able to do that with AssetDatabase.GetAssetPath, so hopefully that'll work!

Lightning fast response! Thanks so much :) Relative paths would be super nice, but I understand it's a low priority thing :D

Developer

Fixed it in v1.4.3! The prefabs are now in the resources folder. I believe that's the only way to get an asset from within a static function like the one that creates GameObjects.

Yes, thank you, that saved me so much time, I was searching for a solution to this for my project!

Yay! Thank you!! :)