This is probably a very basic question, but I wasn’t able to find a solution to my problem.
I have a C# script “Drawing” that has a function “DrawLine” that is called from OnGUI() to draw a line.
In my UnityScript script, I now just want to call this function from the script’s OnGUI(), but I don’t know how (this is my first time using classes).
Code Bits: (I’m only including the basic structure to save space):
Drawing.cs: (is not attached to any gameObject, just sits in the asset folder)
using System.Reflection;
using UnityEngine;
public static class Drawing
{
public static void DrawLine(Vector2 pointA, Vector2 pointB, Color color, float width, bool antiAlias)
{
//here goes to actual line drawing code, etc.
}
}
MainGUI.js:(attached to a gameObject)
function OnGUI()
{
DrawLine(Vector2(100, 100), Vector2(150, 100), Color.white, 1, false);
}
So far I’, getting the error "Assets/Scripts/MainGUI.js(3,9): BCE0005: Unknown identifier: ‘DrawLine’.
I guess I have to create an instance somehow, but after some experimenting in js and c# I didn’t get anywhere