If my class is attachet to an object and extends Monobehaviour and set a transform from another script from another object I always get the “You are trying to create a MonoBehaviour using the new keyword.This is not allowed” warning…any clues on how to solve this ? the scripts actually work but I want to know what the warning means and what side effects it has.
the class script
#pragma strict
class aClass extends MonoBehaviour
{
var pos : Transform;
function aClass(a : Transform)
{
pos = a;
}
function Updater()
{
if(pos != null)
{
Debug.DrawRay(pos.position,Vector3(0,10,0), Color.red);
print("abba");
}
}
}
and the second script
#pragma strict
var grid : aClass;
function Start ()
{
grid = aClass(gameObject.transform);
}
function Update()
{
grid.Updater();
}
the warning appears because the transform in the second script and points at the constructor in the class script.