Unity Class Attributes

using UnityEngine;
using System.Collections;


[ExecuteInEditMode]                                        //allows execution of this Class in edit more
[RequireComponent(typeof(Rigidbody))]    //allows a component to be automatically attached to the inspector
[DisallowMultipleComponent]                      //Avoid to have the same component twice on the inspector
public class ClassProperties : MonoBehaviour {



    void Start() {
        Debug.Log("Start Method");
    }

    private void Update() {
        gameObject.GetComponent().sharedMaterial.color = new Color(Random.Range(0f, 1f),
                                                                             Random.Range(0f, 1f),
                                                                             Random.Range(0f, 1f),
                                                                             Random.Range(0f, 1f));
    }

    [RuntimeInitializeOnLoadMethod]       //Static method will be run, without being called from another class.
    static void RunMeAtLoadTime() {
        Debug.Log("RunMeAtLoadTime - [RuntimeInitializeOnLoadMethod]");
    }



}  

Add a Comment

Your email address will not be published. Required fields are marked *

17 − 6 =