I wrote this script in Visual Studio, opened by default from Unity. When trying to apply it to my background object I get the following message, "Can't add script behaviour VisualContainerAsset. The script needs to derive from MonoBehaviour!"
What am I missing here?
My Script:
public class TiledBackground : MonoBehaviour {
public int textureSize = 32;
// Use this for initialization
void Start () {
var newWidth = Mathf.Ceil (Screen.width / (textureSize * PixelPerfectCamera.scale));
var newHeight = Mathf.Ceil (Screen.height / (textureSize * PixelPerfectCamera.scale));
transform.localScale = new Vector3 (newWidth * textureSize, newHeight * textureSize, 1);
GetComponent ().material.mainTextureScale = new Vector3 (newWidth, newHeight, 1);
}
}
↧