Ejemplo n.º 1
0
    IEnumerator DoImportCharacterGraphics()
    {
        string folderPath = Application.streamingAssetsPath;

        folderPath = System.IO.Path.Combine(folderPath, "CharacterParts");

        string filePathNo = System.IO.Path.Combine(folderPath, "NoFile");

        PlayerProfileSprite = new List <SpriteHolderClass>();

        WWW wwwNo = new WWW(filePathNo);

        if (!wwwNo.isDone)
        {
            yield return(null);
        }

        _noImage = wwwNo.texture;

        foreach (string s in characterFileNames) //import filenames with given name
        {
            string filePath = System.IO.Path.Combine(folderPath, s);
            //PathDebugText.text += filePath + "\n";

            /*if (!File.Exists(filePath))
             * {
             *  PathDebugText.text += s + " no exist\n";
             *  continue;
             * }*/

            WWW www = new WWW(filePath);
            if (!www.isDone)
            {
                yield return(null);
            }
            Texture2D texture = www.texture;

            if (texture.height == _noImage.height)
            {
                //PathDebugText.text += s + " no exist\n";
                continue;
            }

            Sprite partSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));

            SpriteHolderClass temp = new SpriteHolderClass();

            temp.NameString   = s;
            temp.LoadedSprite = partSprite;

            PlayerProfileSprite.Add(temp);
        }
        CharacterCreator.SetGraphicsParts(PlayerProfileSprite);
        PlayerdLoadingDone = true;

        StartCoroutine("CheckLoadingDone");
    }
Ejemplo n.º 2
0
    IEnumerator ImportAI()
    {
        string folderPath = Application.streamingAssetsPath;

        folderPath = System.IO.Path.Combine(folderPath, "AI");
        //PathDebugText.text = folderPath + "\n";
        //DirectoryInfo di = new DirectoryInfo(folderPath);
        //PathDebugText.text += " 1\n";
        //FileInfo[] filesInfo = di.GetFiles(); //do not work on Android
        //PathDebugText.text += "2\n";

        AIProfileSprite = new List <SpriteHolderClass>();

        //PathDebugText.text += "Images found: " + filesInfo.Length +"\n";
        //PathDebugText.text += "Images found: " + importFileNames.Count +"\n";

        foreach (string s in importFileNames) //import filenames with given name
        {
            string filePath = System.IO.Path.Combine(folderPath, s);
            //PathDebugText.text += filePath + "\n";
            WWW www = new WWW(filePath);
            if (!www.isDone)
            {
                yield return(null);
            }

            Texture2D texture  = www.texture;
            Sprite    aiSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));


            SpriteHolderClass temp = new SpriteHolderClass();

            temp.NameString   = s;
            temp.LoadedSprite = aiSprite;

            AIProfileSprite.Add(temp);
        }
        #region oldImportingUsingFileInfoClass
        //FileInof class do not work on android

        /* foreach (FileInfo fi in filesInfo)
         * {
         *   if (fi.Name.Contains(".meta"))
         *   {
         *       continue;
         *   }
         *
         *   string filePath = System.IO.Path.Combine(folderPath, fi.Name);
         *   PathDebugText.text += filePath + "\n";
         *   WWW www = new WWW(filePath);
         *   if (!www.isDone)
         *   {
         *       yield return null;
         *   }
         *
         *   Texture2D texture = www.texture;
         *   Sprite aiSprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
         *
         *
         *   SpriteHolderClass temp = new SpriteHolderClass();
         *
         *   temp.NameString = fi.Name;
         *   temp.LoadedSprite = aiSprite;
         *
         *   AIProfileSprite.Add(temp);
         * }*/
        #endregion
        AILoadingDone = true;
    }