Exemplo n.º 1
0
        Texture2D LoadTexture(string resourceName, int width, int height)
        {
            Texture2D asset = AssetDatabase.LoadAssetAtPath <Texture2D>(XcodeEditor.BasePath() + "/Resources/" + resourceName + ".png");

            if (asset == null)
            {
                Debug.LogError("Failed to load texture: " + XcodeEditor.BasePath() + "/Resources/" + resourceName + ".png");
                return(null);
            }
            return(asset);
        }
Exemplo n.º 2
0
        void LoadTexturesInResourceFile(string fileName)
        {
            using (StreamReader reader = new StreamReader(XcodeEditor.BasePath() + "/Resources/" + fileName))
            {
                while (!reader.EndOfStream)
                {
                    string entry = reader.ReadLine().Trim();

                    if (entry.StartsWith("//"))
                    {
                        continue;
                    }

                    string[] elements = entry.Split(new char[] { ',' }, System.StringSplitOptions.RemoveEmptyEntries);

                    if (elements.Length != 3)
                    {
                        continue;
                    }

                    int w = 0, h = 0;

                    if (!int.TryParse(elements[1], out w))
                    {
                        continue;
                    }

                    if (!int.TryParse(elements[2], out h))
                    {
                        continue;
                    }

                    var tex = LoadTexture(elements[0], w, h);

                    if (tex != null)
                    {
                        _resources.Add(elements[0], tex);
                    }
                }
            }
        }