コード例 #1
0
    void RenderObject(IsoObjectModel objModel, Layer layer)
    {
        GameObject obj = new GameObject("obj");

        obj.transform.position = objModel.position;
        obj.transform.rotation = objModel.rotation;
        obj.transform.SetParent(layer.gameObject.transform);


        IsoObject isoObj = obj.AddComponent <IsoObject> ();

        isoObj.FilePath = objModel.ImgFilePath;
        isoObj.offset   = objModel.offset;
        layer.AddPositionData(obj.transform.position, obj);
        // Read image;
        SpriteRenderer renderer = obj.AddComponent <SpriteRenderer> ();

        renderer.sortingOrder = objModel.SortingOrder;
        Sprite result = resources.Find(x => x.path == isoObj.FilePath).Sprite;

        result          = Ultils.ChangeOffset(result, isoObj.offset);
        renderer.sprite = result;

        obj.AddComponent <PolygonCollider2D> ();
    }