Exemplo n.º 1
0
    private void InstantiateScriptable(WorldData.Sprite s, GameObject worldLayer, WorldData.Layer layer, int i)
    {
        Vector3    pos        = new Vector3(layer.Ratio * (s.x / 10.0f - 5.0f), (100 - s.y) / 10.0f - 5.0f, world.layers.Count - i - (s.zIndex + 1) / 1000.0f);
        float      scale      = layer.Ratio * s.size / 10.0f;
        Quaternion rotation   = Quaternion.Euler(0.0f, 0.0f, -s.rotation);
        string     pathname   = "Scriptables/" + sprites[s.id].name;
        GameObject scriptable = (GameObject)Instantiate((GameObject)Resources.Load(pathname));

        UpdateLayer(scriptable, LayerMask.NameToLayer(worldLayer.name.ToLower()));
        scriptable.transform.parent      = worldLayer.transform;
        scriptable.transform.position    = pos;
        scriptable.transform.localScale *= scale;
        scriptable.transform.rotation    = rotation;
    }
Exemplo n.º 2
0
    private void InstantiateSprite(WorldData.Sprite s, GameObject worldLayer, WorldData.Layer layer, int i)
    {
        Vector3        pos            = new Vector3(layer.Ratio * (s.x / 10.0f - 5.0f), (100 - s.y) / 10.0f - 5.0f, world.layers.Count - i - (s.zIndex + 1) / 1000.0f);
        float          scale          = layer.Ratio * s.size / 10.0f;
        Quaternion     rotation       = Quaternion.Euler(0.0f, 0.0f, -s.rotation);
        GameObject     worldSprite    = (GameObject)Instantiate(_sprite);
        SpriteRenderer spriteRenderer = worldSprite.GetComponent <SpriteRenderer>();
        Sprite         sprite         = sprites[s.id].image;

        spriteRenderer.sprite             = sprite;
        worldSprite.transform.parent      = worldLayer.transform;
        worldSprite.transform.position    = pos;
        worldSprite.transform.localScale *= scale;
        worldSprite.transform.rotation    = rotation;
        worldSprite.layer = worldLayer.layer;
    }