Пример #1
0
    public EntityView CreateView()
    {
        GameObject prefab = Resources.Load <GameObject>(ViewResource);

        if (prefab == null)
        {
            throw new UnityException("View not found: " + ViewResource);
        }

        GameObject go = (GameObject)GameObject.Instantiate(prefab, new Vector3(x, y, 0), Quaternion.identity);

        EntityView ev = go.GetComponent <EntityView>();

        if (ev == null)
        {
            throw new UnityException("EntityView component not found: " + ViewResource);
        }

        View = ev;
        ev.BindData(this);
        return(ev);
    }