Vrtk: Cannot access protected member `UnityEngine.Texture.Texture()`

Created on 16 May 2018  路  22Comments  路  Source: ExtendRealityLtd/VRTK

Environment

  • VRTK imported from the Unity Asset Store.
  • VRTK Version: 3.2.1
  • Version of Unity3D: 2018.1.0f2
  • Hardware used: HTC Vive
  • SDK used: SteamVR

Steps to reproduce

  • Import VRTK to the assets

Expected behavior

  • No error should come up.

Current behavior

  • I am getting two errors:
Assets/VRTK/Scripts/Interactions/Highlighters/VRTK_MaterialColorSwapHighlighter.cs(146,66): error CS1540: Cannot access protected member `UnityEngine.Texture.Texture()' via a qualifier of type `UnityEngine.Texture'. The qualifier must be of type `VRTK.Highlighters.VRTK_MaterialColorSwapHighlighter' or derived from it
Assets/VRTK/Scripts/Interactions/Highlighters/VRTK_MaterialColorSwapHighlighter.cs(146,66): error CS0122: `UnityEngine.Texture.Texture()' is inaccessible due to its protection level

Most helpful comment

That would mean you continue to use the VRTK version that is over a year old. Instead follow best practices to get the latest VRTK by getting it from the GitHub branch.

All 22 comments

Try searching on github issues before posting.

Vrtk 3.2.1 is not supported on unity 2018.1

replace the line giving you the error with this :
renderer.material.SetTexture("_MainTex", new Texture2D(0,0));

good luck!

That would mean you continue to use the VRTK version that is over a year old. Instead follow best practices to get the latest VRTK by getting it from the GitHub branch.

Oh no idea it got updated
Can you provide the link of the latest version please
Thanks!

You're on the repo already! https://github.com/thestonefox/VRTK

Join Slack because you can instantly get answers instead of waiting on here. It's also way easier for troubleshooting in general. GitHub issues are only useful for proper bug reports with steps to reproduce in an example scene like the Issue Template requires.

I had the same issue... using this latest version with 2018.2.2f
adjusting the line in question to this: "renderer.material.SetTexture("_MainTex", new Texture2D(0,0));"
fixed the issue for me : )

I will keep an eye open for an update to VRTK that works with 2018.2 +

@treendy As already explained above you need to use VRTK from GitHub. If you're unable to familiarize yourself on how to do so don't use this comment section, instead go and use the already linked Slack.

Thanks, however, i did already question on Slack, but having found this post it solved my issue (as mentioned above).
Only posting here for others to know what the fix was for my issue.
Also, FYI, i am using the latest gitHub version (as mentioned above), just with a different unity version.

You're definitely not using the GitHub master branch if you get this compile error.

I assume you're using the releases page of GitHub, not the master branch.

For anyone reading this: This issue is marked as closed for a reason. The reason is that it was fixed back in the day in VRTK so no adjustment is necessary if you get the latest VRTK (from the GitHub master).

I downloaded from the master branch... however, I had an issue with a class returning null instead of an empty string which caused my Unity to crash... i cant remember what that related to now and what order my attempts was made.

I will retry with the master and confirm

Thank you for your help

That's unrelated and is already discussed in https://github.com/thestonefox/VRTK/issues/1852 instead.

Thats the one... it was this post that helped me: #1848 ... but as you say, it is unrelated, but will retry the master branch and confirm later (it may have been #1848 issue that caused me to not use the master branch in error)

Unfortunately my experience with the master build didnt go very well, and my personal suggestion would be to apply the temp fix above (which works), then if your unity crashes when trying to run, take a look at #1848, then just wait for a release (which will be more stable than the master)

After downloading the latest master, i now get further errors

"NullReferenceException: Object reference not set to an instance of an object
VRTK.VRTK_TouchpadControl.ControlFixedUpdate () (at Assets/VRTK/Source/Scripts/Locomotion/VRTK_TouchpadControl.cs:58)
VRTK.VRTK_ObjectControl.FixedUpdate () (at Assets/VRTK/Source/Scripts/Locomotion/VRTK_ObjectControl.cs:173)"

also, i have less examples, and when trying to run an example, my Unity crashes (and that is with the #1848 fix included

No. v4 is WIP and not ready to use. Use the GitHub master branch.

I have the exact same error with VRTK 3.3.0 and Unity2018.3.10f1

image

Then you didn't update correctly as 3.3.0 can't have that issue. I suggest you ask for troubleshooting advice on our Slack, I'm sure someone can help you ensure you're importing 3.3.0 into your project correctly!

sorry it seems my Asset Store downloaded an old version instead of the new one... I think because when you already have downloaded the asset long ago, the button is "Import" on the asset store and it import the vesion you bought long time ago...

I swear Unity fixed that back in Unity 5.6 days 馃槥

replace the line giving you the error with this :
renderer.material.SetTexture("_MainTex", new Texture2D(0,0));

good luck!

It's working now!
Thank you so much

renderer.material.SetTexture("_MainTex", new Texture2D(0,0));

yes work

Was this page helpful?
0 / 5 - 0 ratings

Related issues

broehl picture broehl  路  8Comments

dantman picture dantman  路  4Comments

JWNJWN picture JWNJWN  路  4Comments

bgr picture bgr  路  8Comments

monodavids picture monodavids  路  3Comments