예제 #1
0
    // Start is called before the first frame update
    void Start()
    {
        Transform t = this.transform.parent;

        if (t)
        {
            //Debug.Log("Found parent");
            _ws = t.GetComponentInChildren <bWorkerScript>();
            if (_ws)
            {
                // Debug.Log("Found WS");
                GameObject go = _ws.getOwner();
                if (go)
                {
                    _bo = go.GetComponent <BuildableObject>();
                }
                else
                {
                    // bWorker hasn't finished its start setup, need delay
                    StartCoroutine(ReSetup());
                    // Debug.Log("ReSetup");
                }
                FigureOutMode();
            }
            else
            {
                //Debug.Log("Cant find ws in children so Resetup2");
                StartCoroutine(ReSetup2());
            }
        }
    }
예제 #2
0
    IEnumerator ReSetup2()
    {
        yield return(new WaitForSeconds(1f));

        Transform t = this.transform.parent;

        if (t)
        {
            // Debug.Log("Found parent");
            _ws = t.GetComponentInChildren <bWorkerScript>();
            if (_ws)
            {
                // Debug.Log("Found WS");
                GameObject go = _ws.getOwner();
                if (go)
                {
                    _bo = go.GetComponent <BuildableObject>();
                }
                else
                {
                    // bWorker hasn't finished its start setup, need delay
                    StartCoroutine(ReSetup());
                    //Debug.Log("ReSetup");
                }
                FigureOutMode();
            }
        }
    }