Exemple #1
0
        private static void CreateUrdfObject()
        {
            string urdfFile = EditorUtility.OpenFilePanel(
                "Import local URDF",
                Path.Combine(Path.GetDirectoryName(Application.dataPath), "Assets"),
                "urdf");
            // Get existing open window or if none, make a new one:
            FileImportMenu window = (FileImportMenu)EditorWindow.GetWindow(typeof(FileImportMenu));

            window.urdfFile = urdfFile;
            window.minSize  = new Vector2(500, 200);
            window.Show();
        }
        private static void CreateUrdfObject()
        {
            //Get path to asset, check if it's a urdf file
            string assetPath = AssetDatabase.GetAssetPath(Selection.activeObject);

            if (Path.GetExtension(assetPath)?.ToLower() == ".urdf")
            {
                // Get existing open window or if none, make a new one:
                FileImportMenu window = (FileImportMenu)EditorWindow.GetWindow(typeof(FileImportMenu));
                window.urdfFile = UrdfAssetPathHandler.GetFullAssetPath(assetPath);
                window.minSize  = new Vector2(500, 200);
                window.Show();
            }
            else
            {
                EditorUtility.DisplayDialog("URDF Import",
                                            "The file you selected was not a URDF file. Please select a valid URDF file.", "Ok");
            }
        }