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 androids · Jun 14, 2013 at 11:38 AM · changeinvokerepeatingcancelinvoke

Change InvokeRepeating in another script

My problem is that I use this script in 'Script_01';

 var ScoreSkin:GUISkin;
 static var s1lvl1Score: int;
 InvokeRepeating("Add",0, 0.1);
 
 function Add() {
      s1lvl1Score += 1;
 }
 
 function OnGUI(){
     GUI.skin = ScoreSkin;
     
     GUI.Box(Rect(Screen.width*0.475,Screen.height*0.9,200,35), s1lvl1Score.ToString());
     GUI.Label(Rect(Screen.width*0.375,Screen.height*0.9,200, 35), "SCORE :");
 }

Now I want to change in 'Script_02' the InvokeRepeating of 'Script_02'.

This is my script in 'Script_02';

 function OnTriggerEnter(other : Collider){
     if (other.gameObject.CompareTag("CharTag")) {
               //(CHANGE THE InvokeRepeating of 'Script_01'..)//
               //into InvokeRepeating("Add",0, 0);//
     }
 }

Someone who can help me please? :D

EDIT

Please someone help

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

1 Reply

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

Answer by MissingSemicolon · Jun 14, 2013 at 12:13 PM

You might want to look into CancelInvoke:

http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.CancelInvoke.html

You could create two methods inside script01, one that will start the invoke and another to stop it.

One important thing to note, if you want to invoke the same method again but with different parameters to make sure you first cancel the old one, otherwise you will have two running at the same time.

In the start invoke method you can then pass in the parameters you want to change and call this from Script02.

Let me know if this helps.

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 androids · Jun 14, 2013 at 11:22 PM 0
Share

I don't know how to cancel the invokeRepeating of an other script.

Script_01 has: InvokeRepeating(Add, 0, 0.1);

and in Script_02 I use: CancelInvoke("Add");

Can you help me out?

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

15 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 avatar image avatar image avatar image

Related Questions

script help gameobject to playercar 1 Answer

Declaring animations on a script in the editor 1 Answer

Changing camera with different culling mask 1 Answer

What is wrong with my text changing script? 1 Answer

Changing variables in another script 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