Esempio n. 1
0
        private Material OnAssignMaterialModel(Material defaultMaterial, Renderer renderer)
        {
            if (!UseThisImporter())
            {
                return(null);
            }

            // This is the only reliable place to assign materials in the import chain.
            // It kind of sucks because we have to go about making the mesh/material association in a roundabout way.

            // Note: This seems dangerous, but getting to the name of the base gameObject appears to be take some work.
            // The root gameObject, at this point, seems to have "_root" appeneded to it.
            // Once the model if finished being imported it drops this postifx
            // This is something that could change without our knowledge
            string rootName  = renderer.transform.root.gameObject.name;
            int    rootIndex = rootName.LastIndexOf("_root");

            if (rootIndex != -1)
            {
                rootName = rootName.Remove(rootIndex);
            }

#if !UNITY_WEBPLAYER
            ImportTiled2Unity importer = new ImportTiled2Unity(this.assetPath);
            return(importer.FixMaterialForMeshRenderer(rootName, renderer));
#else
            return(null);
#endif
        }
        private UnityEngine.Material OnAssignMaterialModel(Material defaultMaterial, Renderer renderer)
        {
            if (!UseThisImporter())
            {
                return(null);
            }

            // What is the parent mesh name?
            string rootName = System.IO.Path.GetFileNameWithoutExtension(this.assetPath);

#if !UNITY_WEBPLAYER
            ImportTiled2Unity importer = new ImportTiled2Unity(this.assetPath);
            return(importer.FixMaterialForMeshRenderer(rootName, renderer));
#else
            return(null);
#endif
        }
        private Material OnAssignMaterialModel(Material defaultMaterial, Renderer renderer)
        {
            if (!UseThisImporter())
                return null;

            // This is the only reliable place to assign materials in the import chain.
            // It kind of sucks because we have to go about making the mesh/material association in a roundabout way.

            // Note: This seems dangerous, but getting to the name of the base gameObject appears to be take some work.
            // The root gameObject, at this point, seems to have "_root" appeneded to it.
            // Once the model if finished being imported it drops this postifx
            // This is something that could change without our knowledge
            string rootName = renderer.transform.root.gameObject.name;
            int rootIndex = rootName.LastIndexOf("_root");
            if (rootIndex != -1)
            {
                rootName = rootName.Remove(rootIndex);
            }

            ImportTiled2Unity importer = new ImportTiled2Unity(this.assetPath);
            return importer.FixMaterialForMeshRenderer(rootName, renderer);
        }