コード例 #1
0
        public IEnumerator LoadOrGetTexture(Action <Texture2D> callback)
        {
            if (texture)
            {
                callback.Invoke(texture);
                yield break;
            }

            if (!textureLoading)
            {
                textureLoading = true;
                string location;
                if (Path.IsPathRooted(Location))
                {
                    location = Location;
                }
                else
                {
                    location = Application.streamingAssetsPath + "/" + Location;
                }
                yield return(WurmAssetsLoader.LoadTexture(location, false, OnTextureLoaded));
            }

            while (textureLoading)
            {
                yield return(null);
            }

            callback.Invoke(texture);
        }
コード例 #2
0
        private IEnumerator InitializeModel(ModelProperties modelProperties)
        {
            if (!modelsRoot)
            {
                modelsRoot = new GameObject("Models");
                modelsRoot.SetActive(false);
            }
            if (!modelRoot)
            {
                modelRoot = new GameObject(location);
                modelRoot.transform.SetParent(modelsRoot.transform);
            }
            if (!loadingOriginalModel && !originalModel)
            {
                loadingOriginalModel = true;
                string fullLocation = Application.streamingAssetsPath + "/" + location;
                yield return(WurmAssetsLoader.LoadModel(fullLocation, Scale, OnMasterModelLoaded));
            }

            InitializeModifiedModel(modelProperties);
        }
コード例 #3
0
        public IEnumerator LoadOrGetSprite(Action <Sprite> callback)
        {
            if (sprite)
            {
                callback.Invoke(sprite);
                yield break;
            }

            if (texture)
            {
                sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                callback.Invoke(sprite);
                yield break;
            }

            if (!textureLoading)
            {
                textureLoading  = true;
                spriteRequested = true;
                string location;
                if (Path.IsPathRooted(Location))
                {
                    location = Location;
                }
                else
                {
                    location = Application.streamingAssetsPath + "/" + Location;
                }
                yield return(WurmAssetsLoader.LoadTexture(location, false, OnTextureLoaded));

                sprite = Sprite.Create(texture, new Rect(0.0f, 0.0f, texture.width, texture.height), new Vector2(0.5f, 0.5f));
            }

            while (textureLoading)
            {
                yield return(null);
            }

            callback.Invoke(sprite);
        }