コード例 #1
0
        public static GameObject CreateCollider(this Link.Geometry.Mesh mesh, GameObject parent)
        {
            GameObject prefabObject = LocateAssetHandler.FindUrdfAsset <GameObject>(mesh.filename);

            if (prefabObject == null)
            {
                return(null);
            }

            GameObject meshObject = Object.Instantiate(prefabObject);

            MeshFilter[] meshFilters = meshObject.GetComponentsInChildren <MeshFilter>();
            foreach (MeshFilter meshFilter in meshFilters)
            {
                GameObject   child        = meshFilter.gameObject;
                MeshCollider meshCollider = child.AddComponent <MeshCollider>();
                meshCollider.sharedMesh = meshFilter.sharedMesh;
                Object.DestroyImmediate(child.GetComponent <MeshRenderer>());
                Object.DestroyImmediate(meshFilter);
            }

            mesh.setScale(meshObject);
            meshObject.transform.SetParentAndAlign(parent.transform);
            return(meshObject);
        }
コード例 #2
0
        private static Texture LoadTexture(string filename)
        {
            string path = Path.Combine(assetPath, filename).Replace(Path.AltDirectorySeparatorChar, Path.DirectorySeparatorChar);

            if (path == null)
            {
                return(null);
            }
            return(LocateAssetHandler.FindUrdfAsset <Texture>(path));
        }
コード例 #3
0
        public static GameObject CreateVisual(this Link.Geometry.Mesh mesh, GameObject parent)
        {
            GameObject meshObject = LocateAssetHandler.FindUrdfAsset <GameObject>(mesh.filename);

            if (meshObject != null)
            {
                GameObject gameObject = Object.Instantiate(meshObject);
                mesh.setScale(gameObject);
                gameObject.transform.SetParentAndAlign(parent.transform);
                return(gameObject);
            }
            return(null);
        }
コード例 #4
0
 private static Texture LoadTexture(string filename)
 {
     return(filename == "" ? null : LocateAssetHandler.FindUrdfAsset <Texture>(filename));
 }