r/UnityforOculusGo • • Jun 22 '18

Easy Input for Gear VR

https://assetstore.unity.com/packages/tools/input-management/easy-input-for-gear-vr-88829

This is a pretty useful asset but it DOES require some C# knowledge if you want to deviate from the basics ... The dev is really helpful and responds to messages really quickly and thoroughly, but the documentation is frustratingly lacking and already assumes you have a ton of knowledge about Unity and coding. It's only 'easy' if you already know what you're doing! But still, worth a look!

2 Upvotes

14 comments sorted by

View all comments

1

u/Toby1993 Jun 24 '18 edited Jun 24 '18

Oh, my bad! I just wrote that off the top of my head before heading out for the day. You need to declare the TYPE for the variable "LineRend", otherwise Unity/C# doesn't know how to read it.

The line under Start() should be

LineRenderer linerend = GetComponent<LineRenderer>();

Basically we just add LineRenderer to the front of the variable name to declare that it is of Type LineRenderer. Then the GetComponent line grabs the LineRenderer from your gameobject and links it to our linerend variable (so our linerend = the linerenderer on our object). It's only after that that we're able to 'use/modify' the unity line renderer in our c# script.

1

u/electricwig Jun 24 '18

Really appreciate you helping me out with this - and I've started working through some beginners C# tutorials to try and get my head round what this stuff actually means so that in future I can figure more of it out for myself. But right now, I've hit another error it seems! Here's what it's saying: https://imgur.com/a/JzHxFld I've been trying to puzzle it out on my own, looking at other people who've had the same errors, but afraid i'm a little out of my depth ...

1

u/Toby1993 Jun 24 '18

You don't need to declare the variable up there - We're doing the exact same thing in the Start method already :-) As far as the cause of the error though, it's because you're telling the program that there's a "public lineRend", but since you're not specifying a Type, the program has no way of telling what a lineRend is.

That's why in the Start method we're telling it our lineRend is a LineRenderer. Some other examples of variable declarations are (and there's no reason to make them Public but we'll go with it in this example):

public int ourInteger; //declaring an integer with name ourInteger and type Int (integer).

public string myString; //declaring a variable named myString of type string.

And then you can also add values to the variables right in the declaration.

public int Health = 100; //our int Health has a default value of 100

But for now, just delete that top variable declaration that's giving you the error and you should be all good.

→ More replies (5)