- Home /
Using variables from UnityScript in Boo?
Hello, I've been trying to implement this but without any success. While I was googling around I saw that this is somehow possible but I can't reach it by myself obviously. This my file tree:
|-Game
|--Assets
|---Animacije
|---Skripte
|----*BlokSistem.js
|---Standard Assets
|----*UI.boo
|---Prefabs
|---Sprites
|---Game.unity
I want to use variable from BlokSistem.js in UI.boo, but without any success. I want to change one and print another. Here is my code for now:
import UnityEngine
import System.Collections
public class UI(MonoBehaviour):
blokSistem as BlokSistem = GetComponent[of BlokSistem]() #this is line 7 which produces error
def OnGUI() as void:
GUI.Box(Rect(0,0,200,50), "Blocks")
if GUI.Button(Rect(0,60,200,25), "Dirt = "+blokSistem.dirtAmount):
blokSistem.selectedBlock = blokSistem.dirtBlock
elif GUI.Button(Rect(0,60,200,25), "Grass = "+blokSistem.grassAmount):
blokSistem.selectedBlock = blokSistem.grassBlock
I get this error on line 7 (commented it in code above):
The name 'BlokSistem' does not denote a valid type ('not found').
This is how I declared my variables in BlokSistem.js:
public var dirtAmount : int;
public var grassAmount : int;
public var selectedBlock : GameObject;
Thanks in advance for help.
Answer by Mr. Mud · Feb 02, 2015 at 11:35 AM
For this to work, the javascript code needs to be compiled before the booscript is compiled. This is done by placing all (or most) javascripts in the folder "Standard Assets" or a subfolder of it. Your Boo scripts should be in a different folder. Here is the documentation about it.
+1
Additionally "UI" is not a good class name since Unity has an namespace called UI. Try to avoid too short and existing identifiers.