I just can't get RequiredComponent to work
I've been working on converting an asset from JS to C# and the last piece I'm stuck on is the implementation of the RequiredComponent code.
The asset has classes for things like Character, Item, Inventory. Those various scripts should have a [RequiredComponent(Item)] for example, but the class could just as easily be Character, Inventory, or many of the others. None of them work. I just get an error:
"'Item' is a type, which is not valid in the given context"
I've tried rewriting it every way I can think, [RequiredComponent(typeof(Item))], [RequiredComponent("Item")], [RequiredComponent(GetComponent())], and many many more.
I've spent hours on this now and it's the last thing I need to work through to finish. So I'm really hoping someone has some insight..
Thanks for reading!
Answer by Pengocat · Feb 14, 2017 at 03:53 AM
It is Require not Required. example [RequireComponent (typeof (Rigidbody))]
Answer by Julac · Feb 14, 2017 at 04:22 AM
Sorry that was a mistype here, I have it typed correctly in my program. The only error is trying to pass in one of my classes as a parameter.
Your answer
Follow this Question
Related Questions
How do you change UI Text to an int? 4 Answers
random spawn enemy problem 0 Answers
show textwindow on mouseclick 0 Answers
I am trying to reference a bool from another script but the only value that it returns is false 0 Answers
script an delay 0 Answers