Search Unity

Unity Framework

Discussion in 'Scripting' started by JYKeith, Sep 2, 2014.

  1. JYKeith

    JYKeith

    Joined:
    Aug 17, 2014
    Posts:
    12
    Hi guys-!
    I have a question about unity framework.
    normally we use script like below (basic template)


    using UnityEngine;
    using System.Collections;

    public class helloworld : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

    // Update is called once per frame
    void Update () {

    }
    }​


    Start, Update or OnEnable such methods would be called at proper time.
    But I wonder,, How could it be the methods are private?
    It's not virtual function, and maybe unity call it somewhere...

    weird..

    anybody help me!
     
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    I know that this could sound stupid but... Just take it like that , it works the functions get called.
    Unity does not care if the function is public or private.
    for the "proper time" you can take a look at this chart
    http://docs.unity3d.com/Manual/ExecutionOrder.html
     
    JYKeith likes this.
  3. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    They are invoked by reflection.
     
    JYKeith likes this.
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    3,276
    How does it works on iOS? I thought always that reflections re not available on iOS.
     
    JYKeith likes this.
  5. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,717
    Only some things are not available by reflection on iOS, like emitting new IL. Basic "passive" reflection, like GetType, GetFields, GetMethods and Invoke work fully on iOS.
     
    JYKeith and fffMalzbier like this.