Esempio n. 1
0
    public void OnEnable()
    {
        instance = (MyMonoBehaviour)target;

        prefabProperty = serializedObject.FindProperty("prefab");
        amountProperty = serializedObject.FindProperty("amount");
        offsetProperty = serializedObject.FindProperty("offset");
    }
Esempio n. 2
0
    /* Instantiates non-MonoBehaviours and utilities. */
    void Awake()
    {
        if (!initializedNonMonos)
        {
            if (showDebug) Debug.Log("_____MyMonoBehaviour: Performing first-time initialization_____");

            /* Utilities */
            instance = this;
            InstantiateDatabases();

            initializedNonMonos = true;

            if (showDebug) Debug.Log("_____MyMonoBehaviour: First-time initialization complete_____");
        }
    }
Esempio n. 3
0
        public void NullCoalescing(MyMonoBehaviour mb)
        {
            var behaviour = mb ?? gameObject.AddComponent <MyMonoBehaviour>();

            if (behaviour?.CompareTag("foo") == true)
            {
                // ...
            }

            var coolRenderer = GetComponent <Renderer>();

            if (coolRenderer == transform)
            {
            }
        }
 public void DoSomething(GameObject go)
 {
     var behaviour        = new MyMonoBehaviour();
     var scriptableObject = new MyScriptableObject();
 }
Esempio n. 5
0
    static public GameObject Spawn(GameObject ObjectClass, MyMonoBehaviour ParentComponent, UnityAction <GameObject> Initializer = null)
    {
        Assert.IsNotNull(ParentComponent);

        return(Spawn(ObjectClass, ParentComponent.gameObject, Initializer));
    }
Esempio n. 6
0
    // These functions allow us to spawn GameObjects using an optional delegate for initialization prior to Awake and Start being called
    static public T Spawn <T>(T ComponentClass, MyMonoBehaviour ParentComponent, UnityAction <T> Initializer = null) where T : MyMonoBehaviour
    {
        Assert.IsNotNull(ParentComponent);

        return(Spawn(ComponentClass, ParentComponent.gameObject, Initializer));
    }
Esempio n. 7
0
 public void Initialization(GameObject gameObject)
 {
     this.gameObject = gameObject;
     rigidbody       = MyMonoBehaviour.AddComponentIfNotExits_noWarning <Rigidbody>(gameObject);
     collider        = MyMonoBehaviour.AddComponentIfNotExits_noWarning <Collider>(gameObject);
 }