- Home /
How do I make sure a resource is loaded or is instantiated?
How do I make sure a resource is loaded or is instantiated?
I have
cube=Instantiate(Resources.Load("cube"));
But I cannot do any operations on it such as scaling or rotating immediately after these lines unless they are in another function and there is a delay. No errors are given, but the object will not receive any transforms like scale or rotate. Is there some way to yield until the object is fully instantiated or loaded?
Thanks, Dan
Answer by Gillissie · Oct 20, 2011 at 05:17 AM
As far as I know, you should be able to transform the cube immediately after instantiating it. I do it all the time. What does your code look like right after you instantiate the cube?
It's very simple just cube.transform.localScale=Vector3(1,2,1); stuff like that.
That kind of thing works for me all the time. Oh, try new before Vector3, assu$$anonymous$$g you're using C#. I think it would throw an error if you didn't, but just making sure.
Answer by Eric5h5 · Oct 24, 2011 at 05:48 AM
There isn't any delay (as far as code goes), Instantiate and Resources.Load functions always return immediately. The only time any delay is a possibility is with AsyncOperation, and there's not much that uses it. You can see in the docs if something returns AsyncOperation, such as LoadLevelAsync.
Your answer
Follow this Question
Related Questions
WaitUntil Combined With sqrMagnitude is not working? 1 Answer
Resources.Load can not get my characters visible 1 Answer
yield wait error iterator block 2 Answers
Wierd issue with Coroutines? 2 Answers