0

Let me be more specific here: This is used in Unity 2017 so the syntax they are using is this:

class CameraMotionBlurEditor extends Editor 
{   
  var preview : SerializedProperty;
  var previewScale : SerializedProperty;
...
  function OnInspectorGUI () {
    if (preview.boolValue) dosomething()
  }
}

What I'm getting errors in is this preview.boolValue reference.. it claims it's ambiguous so therefore whatever this class is extending, must also have a declaration of that variable name. What I don't know is how to specify the local one.

1
  • this.preview.boolValue Commented Jan 25, 2018 at 19:48

1 Answer 1

0

The this keyword is used to refer to the current instance of the class. Retrieving the preview.boolValue from the current instance of the class hence becomes this.preview.boolValue:

function OnInspectorGUI () {
  if (this.preview.boolValue) dosomething()
}

Note that UnityScript is slowly becoming deprecated, and the recommended route of action is to instead program Unity scripts in C#.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.