private GameObject ConvertSprite(Sprite aSprite)
        {
            Texture2D editableTexture = this.GetReadableTexture(aSprite.texture);

            //Create simple container object
            GameObject rootObject = new GameObject();

            rootObject.transform.position = new Vector3(0f, 0f, 0f);
            rootObject.name = StaticValues.baseObjectNamePrefix + aSprite.name;
            //Create Voxel container component for the root object
            VoxelContainer voxelContainer = rootObject.AddComponent <VoxelContainer>();

            voxelContainer.ConvertTexture(editableTexture, aSprite.textureRect.min, aSprite.textureRect.max, this.alphaColor, this.alphaTolerance);
            voxelContainer.BuildOptimizedMesh(false);

            string assetPath = "Assets/" + StaticValues.voxelizerRootFolder + "/" + StaticValues.animationPrefabsFolder + "/" + rootObject.name + ".prefab";

            PrefabUtility.CreatePrefab(assetPath, rootObject);
            DestroyImmediate(rootObject);
#if UNITY_5_0
            return((GameObject)AssetDatabase.LoadAssetAtPath(assetPath, typeof(GameObject)));
#else
            return(AssetDatabase.LoadAssetAtPath <GameObject>(assetPath));
#endif
        }
예제 #2
0
        private void ExtrudePart(Texture2D curTexture, Vector2 startPos, Vector2 endPos)
        {
            //Create simple container object
            GameObject rootObject = new GameObject();

            rootObject.transform.position = new Vector3(0f, 0f, 0f);
            rootObject.name = StaticValues.baseObjectNamePrefix + curTexture.name;
            //Create Voxel container component for the root object
            VoxelContainer voxelContainer = rootObject.AddComponent <VoxelContainer>();

            voxelContainer.ConvertTexture(curTexture, startPos, endPos, this.alphaColor, this.alphaTolerance);
        }