Getting a custom class to contain a certain script.

I have a custom class called block which looks like this:

    public class Block
        public string name;
        public Texture blockTex;
        public GameObject block;
        public int SpawnChance;

I want this class to contain an already made script called canRender which does exactly what you would think it does:

using UnityEngine;
using System.Collections;

public class canRender : MonoBehaviour {
	// Update is called once per frame
	void OnBecameVisible() {
        enabled = true;

    void OnBecameInvisible()
        enabled = false;

Any help is appreciated thanks :slight_smile:

Given that Block class is not derived from MonoBehaviour, I don’t know how you can directly structure this. ‘canRender’ only exists if attached to a game object. Also the ‘enabled’ flag is inherited from MonoBehaviour which inherits it from Behaviour. The Block class will not inherit and enabled flag.

Each block could have a ‘canRender’ component and then you could access the ‘canRender’ component from within the Block class to get access to the state of the ‘enabled’ flag.