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 /
This question was closed Nov 01, 2014 at 03:01 PM by robertbu for the following reason:

Duplicate Question

avatar image
0
Question by Kitos14 · Nov 01, 2014 at 03:01 PM · javascriptmethodglobalsettersgetters

Javascript : Get variable & run a method from another script

I have this 3 javascript scripts :

GameSetup.js

 function Start () {
     // Run Map.Start
 }

A function of Map.js

 function Start () {
     var map = new Array(6);
     var i : int;
     var j : int;
 
     // We do this do avoid OutOfBounceException
     for (i = 0; i < 6; i++) {
     map[i] = new Array(6);
     }
     for (i = 0; i < 6; i++) {
         for (j = 0; j < 6; j++) {
             map[i][j] = -1;
         }
     }

and a function of BoxControl.js

 function Update() {
     var i : int;
     var j : int;
     if(Input.GetKey(moveUp)){
         for (i = 2; i <= 5; i++) {
             for (j = 2; j <= 5; j++) {                   
                 map[i][j] = 1;
         }
     }

1. I want to run the Map.Start function from the GameSetup.

2. And after creating the map I want to send the map array to the BoxControl so I can modify the map.

Comment
Add comment · Show 1
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 robertbu · Nov 01, 2014 at 03:03 PM 0
Share

Accessing other game objects is the most frequently asked question on Unity Answers with 1000s of posts. Take a look at this link:

http://docs.unity3d.com/412/Documentation/ScriptReference/index.Accessing_Other_Game_Objects.html

Note that 'Start()' in your $$anonymous$$ap.js will be called automatically after $$anonymous$$ap.js is attached to a game object.

0 Replies

  • Sort: 

Follow this Question

Answers Answers and Comments

2 People are following this question.

avatar image avatar image

Related Questions

Accessing class properties through getters & setters in editor mode 1 Answer

Abstract Inheritance and abstract variables sloppy code 1 Answer

global variable doesn't work 2 Answers

C# generics and getters/setters with Unity iPhone 1 Answer

How to make a GLOBAL variable in javascript (Unity) 0 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