Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by gringofxs · Nov 15, 2012 at 08:54 PM · touch

An instance required.

this is the error . Assets/b2.js(27,18): BCE0020: An instance of type 'MyScriptName' is required to access non static member 'vuforiaVisible'.

how can i fix it.

 var myObject : GameObject;
 var yourScriptInstance : MyScriptName;
 
 function Start(){
 myObject = GameObject.Find("teapot");
 yourScriptInstance=myObject.GetComponent(MyScriptName); 
 //MyScriptName is your script with var enabledState:bool=true;var vuforiaVisible:bool=false;
 }
 
 function Update () {
 if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){
 if (guiTexture.HitTest(Input.GetTouch(0).position)){
 if (MyScriptName.vuforiaVisible)
 {
 
 myObject.renderer.enabled = myScript.enabledState!=myScript.enabledState;
 }
 }
 
 }
 }
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

2 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by sirival · Nov 15, 2012 at 09:42 PM

Change this line:

if (MyScriptName.vuforiaVisible)

to:

if (yourScriptInstance.vuforiaVisible)

Comment
Add comment · Show 9 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sparkzbarca · Nov 15, 2012 at 09:46 PM 0
Share

hey thats my answer, I got it first! :P

though admittedly i wrote a short explanation. yours is just the short answer.

avatar image Memige · Nov 15, 2012 at 09:48 PM 0
Share

Sparkz is right, this answer was already posted

avatar image sparkzbarca · Nov 15, 2012 at 09:53 PM 0
Share

sorry maybe repost a new question. I don't do mobile and don't know image tracking. I mean you have a vuforia visible but presumably the bool vuforiavisible is true even when the object leaves the screen. the vuforiavisible code would need to be seen but it would need to be seen by someone who know how to manipulate vuforia images. :P

avatar image gringofxs · Nov 15, 2012 at 09:54 PM 0
Share

ok, sorry, and thank you very much for the attention.

avatar image sirival · Nov 15, 2012 at 09:56 PM 0
Share

I'm sorry about the duplicate answer I actually posted before you posted yours but due to my low karma the answer had to be approved by a moderator...

Show more comments
avatar image
2

Answer by sparkzbarca · Nov 15, 2012 at 09:31 PM

oh my bad you did it right. I was speaking of C# your using UnityScript.

Basically what the error says is that this line here

if(MyScriptName.vuforiaVisible)

doesn't make sense because MyScriptName is a class not a variable

what you actually want is

if(yourScriptInstance.vuforiaVisible)

yourScriptInstance is an instance of the variable.

mark as answered

Comment
Add comment · Show 4 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image gringofxs · Nov 15, 2012 at 09:39 PM 0
Share

pragma strict

function Start () {

}

var enabledState:boolean=true;var vuforiaVisible:boolean=false;

function Update () {

}

avatar image gringofxs · Nov 15, 2012 at 09:39 PM 0
Share

error Assets/b2.js(33,29): BCE0005: $$anonymous$$ identifier: 'myScript'.

Assets/b2.js(33,52): BCE0005: $$anonymous$$ identifier: 'myScript'.


var myObject : GameObject; var yourScriptInstance : $$anonymous$$yScriptName;

function Start(){ myObject = GameObject.Find("$$anonymous$$pot"); yourScriptInstance=myObject.GetComponent($$anonymous$$yScriptName); //$$anonymous$$yScriptName is your script with var enabledState:bool=true;var vuforiaVisible:bool=false; }

function Update () { if (Input.touchCount > 0 && Input.GetTouch(0).phase == TouchPhase.Began){ if (guiTexture.HitTest(Input.GetTouch(0).position)){ if(yourScriptInstance.vuforiaVisible)

{

myObject.renderer.enabled = myScript.enabledState!=myScript.enabledState; } }

} }


The other script is attach to the 3D $$anonymous$$pot, the script name is $$anonymous$$yScriptName. Is this one


pragma strict

function Start () {

}

var enabledState:boolean=true;var vuforiaVisible:boolean=false;

function Update () {

}

avatar image sparkzbarca · Nov 15, 2012 at 09:42 PM 0
Share

you just need to change the if statement i mentioned in my answer.

Is that not working for you?

avatar image Memige · Nov 15, 2012 at 09:45 PM 0
Share

You have 'myScript.enabledState != myScript.enabledState' first off, this will always be false, second, you never defined 'myScript'

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

12 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

[Edited]-Android-swap position on touch 1 Answer

Drag an object to touch position(Problem) 1 Answer

iOS multiTouch / release - Strange problem 0 Answers

rect.Contains problem? 2 Answers

Taking Input from Android phones 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges