/// <summary>
    /// 第一引数の葉オブジェクトのテクスチャを第二引数のパスにあるものに変更する
    /// </summary>
    /// <param name="_gameObject">変更される葉</param>
    /// <param name="textureID">変更するテクスチャのパス</param>
    private void SetLeafSprite(GameObject _gameObject, int textureID)
    {
        var MainImage  = _gameObject.GetComponent <Image>();
        var NewTexture = new Texture2D(128, 128);

        if (textureID < MaxStampIconNumber)
        {
            NewTexture = Resources.Load(GraphicsPath.Name + "/" + textureID) as Texture2D;
        }
        else
        {
#if UNITY_METRO && !UNITY_EDITOR
            var FolderName = GraphicsPath.Name + "/";
            var FileName   = textureID + ".png";
            var Bytes      = LibForWinRT.ReadFileBytes(FolderName + FileName).Result;
            NewTexture.LoadImage(Bytes);
#else
            var FolderName = Application.persistentDataPath + "/" + GraphicsPath.Name + "/";
            var FileName   = textureID + ".png";
            var Bytes      = File.ReadAllBytes(FolderName + FileName);
            NewTexture.LoadImage(Bytes);
#endif
        }

        _gameObject.GetComponent <LeafIDSetting>().ID = textureID;

        var NewSprite = Sprite.Create(NewTexture, new Rect(0, 0, NewTexture.width, NewTexture.height), Vector2.zero);
        MainImage.sprite = NewSprite;
    }
예제 #2
0
    protected virtual void TextureLoad(GameObject clone, CharacterData chara)
    {
#if UNITY_METRO && !UNITY_EDITOR
        var filePath = chara.Name + "/" + (chara.ID - 1) + ".png";

        var bytes = LibForWinRT.ReadFileBytes(filePath).Result;
#else
        var filePath = Application.persistentDataPath + "/" + chara.Name + "/" + (chara.ID - 1) + ".png";

        if (!File.Exists(filePath))
        {
            return;
        }
        var bytes = File.ReadAllBytes(filePath);
#endif
        if (bytes == null)
        {
            return;
        }

        var texture = new Texture2D(128, 128);
        texture.LoadImage(bytes);

        if (Name == "Fairy")
        {
            clone.transform.FindChild("fairy").renderer.material.mainTexture = texture;
        }
        else
        {
            clone.renderer.material.mainTexture = texture;
        }
    }
예제 #3
0
    /// <summary>
    /// ファイルのバイト配列を取得
    /// </summary>
    /// <param name="folderPath">フォルダーパス</param>
    /// <param name="ID">ID</param>
    /// <returns></returns>
    static byte[] GetFileBytes(string filePath)
    {
#if UNITY_METRO && !UNITY_EDITOR
        return(LibForWinRT.ReadFileBytes(filePath).Result);
#else
        if (!File.Exists(filePath))
        {
            return(null);
        }

        return(File.ReadAllBytes(filePath));
#endif
    }
예제 #4
0
    protected override void TextureLoad(GameObject clone, CharacterData chara)
    {
        var texture = new Texture2D(128, 128);


        if (chara.ID < MaxResroucesLeaf)
        {
            texture = Resources.Load(chara.Name + "/" + chara.ID) as Texture2D;
        }
        else
        {
#if UNITY_METRO && !UNITY_EDITOR
            var bytes = LibForWinRT.ReadFileBytes(chara.Name + "/" + chara.ID + ".png").Result;
#else
            var bytes = File.ReadAllBytes(Application.persistentDataPath + "/" + chara.Name + "/" + chara.ID + ".png");
#endif
            texture.LoadImage(bytes);
        }

        foreach (Transform child in clone.transform)
        {
            child.renderer.material.mainTexture = texture;
        }
    }