コード例 #1
0
        private IEnumerator LoadMesh(ObjectAsset modAsset, string objectPath)
        {
            var mesh       = _objImporter.ImportFile(objectPath);
            var meshFilter = modAsset.AddComponent <MeshFilter>();

            meshFilter.mesh = mesh;
            yield return(new WaitForEndOfFrame());

            modAsset.SetMeshFilter(meshFilter);
        }
コード例 #2
0
        private IEnumerator LoadTexture(ObjectAsset modAsset, string imagePath)
        {
            var texture = new Texture2D(4, 4, TextureFormat.DXT1, false);
            var url     = "file://" + imagePath;

            using (var www = new WWW(url))
            {
                yield return(www);

                www.LoadImageIntoTexture(texture);
            }
            if (texture == null)
            {
                _console.WriteLine("Texture is null");
            }
            var meshRenderer = modAsset.AddComponent <MeshRenderer>();

            meshRenderer.material.mainTexture = texture;
        }