Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

How to access script variables from another script?

Discussion in 'Scripting' started by Talon911, Aug 3, 2015.

  1. Talon911

    Talon911

    Joined:
    Jul 25, 2015
    Posts:
    7
    Hello, I've a problem - I can't access variables from other scripts.



    OutlineController.js
    Code (JavaScript):
    1. public static var outlinesize_ = 0.7;
    InlineController.js
    Code (JavaScript):
    1. public static var inlinesize_ = 0.3;
    PlayerController.js
    Code (JavaScript):
    1. #pragma strict
    2.  
    3. // Targets
    4. function Start () {
    5.     var outlinescript_ : OutlineController = outlineobject_.GetComponent("OutlineController");
    6.     var inlinescript_ : InlineController = inlineobject_.GetComponent("InlineController");
    7.     // I can't choose my variables
    8.     outlinescript_. <- !
    9.     inlinescript_. <- !
    10. }
    Since 2 days I was researching, but I still have no solution.
    Does anyone has a solution for Unity 5.1.2f1?
     
  2. LeftyRighty

    LeftyRighty

    Joined:
    Nov 2, 2012
    Posts:
    5,148
  3. Talon911

    Talon911

    Joined:
    Jul 25, 2015
    Posts:
    7