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 whitness · Jul 30, 2014 at 08:23 AM · c#script referencing

error CS0131 Assets/route1.cs(12,25): error CS0131: The left-hand side of an assignment must be a variable, a property or an indexer.

really would like some help to make this right. i know its probably something easy I just keep running into a blank wall. first script:

public class route1 : MonoBehaviour {

 public bool r1;

 void OnMouseDown()
 {
     if (r1 = true)
     {
         WR_R1 = true; // line im having troubles with 
     }
         else  if (r1 = false)
         {
             Debug.Log ("wrong play");
         }
 }

}

Second script:

public class WR_R1 : MonoBehaviour {

 void Update(){
     iTween.MoveTo(gameObject, iTween.Hash("path", iTweenPath.GetPath("WR_R1"), "time", 9.5));
     }

}

Any help or a point into the right direction would be great and very helpful.

Comment
Add comment · Show 5
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 meat5000 ♦ · Jul 30, 2014 at 08:33 AM 0
Share

Are you trying to check for the existence of a script/class?

http://answers.unity3d.com/questions/44828/test-if-object-has-a-certain-script.html

avatar image whitness · Jul 30, 2014 at 08:43 AM 0
Share

no i'm trying to set a script active from another if the first one is selected

avatar image meat5000 ♦ · Jul 30, 2014 at 08:47 AM 0
Share

Arc's method should work. However, when I attempted something similar some time ago I could only enable/disable the gameObject itself; perhaps I was doing it, wrongly.

One thing to note is that when a script is Re-Enabled, the Start method will not run automatically, so if it is essential you will need to manually Invoke Start() to make sure your script is ready to go.

If @Arcadewiz's answer works for you, please mark is as Accepted with the tick.

avatar image whitness · Jul 30, 2014 at 08:50 AM 0
Share

thank you for the tip but as of now i'm not using the Start method on anything because I don't want anything started when the level is loaded just to run certain animations after it has been selected.

thanks for re$$anonymous$$ding me about that.

avatar image Arcadewiz · Jul 30, 2014 at 09:10 AM 0
Share
 GameObject WRObj;
 
 WRObj = GameObject.Find("WR");
 // Note 1. This is only if WR is not a child in the hierarchy view
 // Note 2. If it is a child then,
 // WRObj = GameObject.Find("Parent/(Subparent degree names)*/WR");
 WRObj.GetComponent().enabled = true;
 
 This should solve your problems.

2 Replies

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Arcadewiz · Jul 30, 2014 at 08:34 AM

First you have to reference the script WR_R1, by using GetComponent to a referenced gameobject to which it is attached. The gameobject can be referenced by Gameobject.Find.

Then if I understand correctly you need to enable the referenced script on the gameobject if it is disabled.

WR_R1.enabled = true;

Is this what you are trying to do ?

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 whitness · Jul 30, 2014 at 08:35 AM 0
Share

yes that is exactly what i am trying to do thank you ill check it out right now.

avatar image whitness · Jul 30, 2014 at 08:47 AM 0
Share

so another question how exactly do I use GetComponent and where does it go?? The object that the script is on is called WR.

avatar image meat5000 ♦ · Jul 30, 2014 at 09:14 AM 1
Share

GetComponent is very versatile. There are thousands of examples on it. Please search.

avatar image whitness · Jul 30, 2014 at 09:28 AM 0
Share

I have searched a lot and could not fully grasp the idea of how I needed to add it to my script or even where to add it but thanks for all the help.

avatar image
1

Answer by Asphyxion · Jul 30, 2014 at 11:06 AM

If I look at your error message you're getting and your first script, all I can see is that you're checking your boolean value in an incorrect way.

Instead of "if (r1 = true)" you should write "if (r1 == true)" or just "if (r1)".

 public bool r1;
  
 void OnMouseDown()
 {
     if (r1 == true)
     {
         WR_R1 = true; // line im having troubles with 
     }
     else  
     {
         Debug.Log ("wrong play");
     }
 }


Comment
Add comment · Show 1 · 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 meat5000 ♦ · Jul 30, 2014 at 11:20 AM 0
Share

Well spotted

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

5 People are following this question.

avatar image avatar image avatar image avatar image avatar image

Related Questions

Multiple Cars not working 1 Answer

Distribute terrain in zones 3 Answers

Illuminating a 3D object's edges OnMouseOver (script in c#)? 1 Answer

Noob q: how to access functions in script that is in asset folder/view? 1 Answer

Flip over an object (smooth transition) 3 Answers


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