Пример #1
0
    // Use this for initialization
    void Start()
    {
        if (textDisplayUI == null)
        {
            textDisplayUI = gameObject.GetComponent <Text>();
            if (textDisplayUI == null)
            {
                Debug.LogWarning("DisplayPrice requires a Text script be on the same gameobject, or that you provice a link to a Text object. Disabling.");
            }
        }

        if (maximumObject != null)
        {
            _obj = maximumObject.GetComponent <IMaximum>();
        }
        else
        {
            _obj = gameObject.GetComponentInChildren <IMaximum>();

            if (_obj == null)
            {
                _obj = gameObject.GetComponentInParent <IMaximum>();
            }
        }//else
        if (_obj == null)
        {
            Debug.LogWarning("DisplayMaximum requires a script that implements IMaximum be be in the same heirarchy, or that you provide a link to an IMaximum-implmenting object. Disabling.");
        }

        enabled = (textDisplayUI != null && _obj != null);
    }
    // Use this for initialization
    void Start()
    {
        if (textDisplayUI == null)
        {
            textDisplayUI = gameObject.GetComponent <Text>();
            if (textDisplayUI == null)
            {
                Debug.LogWarning("DisplayQuantAndMax requires a Text script be on the same gameobject, or that you provice a link to a Text object. Disabling.");
            }
        }

        //Note: This will probably pull the same object f or both _Mobj and _Qobj. That's ok.
        if (targetObject != null)
        {
            _Mobj = targetObject.GetComponent <IMaximum>();
            _Qobj = targetObject.GetComponent <IQuantity>();
        }
        else
        {
            //Check the children
            _Mobj = gameObject.GetComponentInChildren <IMaximum>();
            _Qobj = gameObject.GetComponentInChildren <IQuantity>();

            //Check the parent
            if (_Mobj == null)
            {
                _Mobj = gameObject.GetComponentInParent <IMaximum>();
            }

            if (_Qobj == null)
            {
                _Qobj = gameObject.GetComponentInParent <IQuantity>();
            }
        }//else


        if (_Mobj == null || _Qobj == null)
        {
            Debug.LogWarning("DisplayQuantAndMax requires a script that implements IMaximum AND IQuantity be be in the same heirarchy, or that you provide a link to an implementing object. Disabling.");
        }

        enabled = (textDisplayUI != null && _Qobj != null && _Mobj != null);
    }