コード例 #1
0
        private static string LocateAssetFile(string invalidPath)
        {
            string fileExtension = Path.GetExtension(invalidPath)?.Replace(".", "");

            string newPath = EditorUtility.OpenFilePanel(
                "Couldn't find asset at " + invalidPath + ". Select correct file.",
                UrdfAssetPathHandler.GetPackageRoot(),
                fileExtension);

            return(UrdfAssetPathHandler.GetRelativeAssetPath(newPath));
        }
コード例 #2
0
 private static void MoveMaterialsToNewLocation(string oldPackageRoot)
 {
     if (AssetDatabase.IsValidFolder(Path.Combine(oldPackageRoot, MaterialFolderName)))
     {
         AssetDatabase.MoveAsset(
             Path.Combine(oldPackageRoot, MaterialFolderName),
             Path.Combine(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName));
     }
     else
     {
         AssetDatabase.CreateFolder(UrdfAssetPathHandler.GetPackageRoot(), MaterialFolderName);
     }
 }
コード例 #3
0
        public static T FindUrdfAsset <T>(string urdfFileName) where T : UnityEngine.Object
        {
            string fileAssetPath = UrdfAssetPathHandler.GetRelativeAssetPathFromUrdfPath(urdfFileName);
            T      assetObject   = AssetDatabase.LoadAssetAtPath <T>(fileAssetPath);

            if (assetObject != null)
            {
                return(assetObject);
            }

            //If asset was not found, let user choose whether to search for
            //or ignore the missing asset.
            string invalidPath = fileAssetPath ?? urdfFileName;
            int    option      = EditorUtility.DisplayDialogComplex("Urdf Importer: Asset Not Found",
                                                                    "Current root folder: " + UrdfAssetPathHandler.GetPackageRoot() +
                                                                    "\n\nExpected asset path: " + invalidPath,
                                                                    "Locate Asset",
                                                                    "Ignore Missing Asset",
                                                                    "Locate Root Folder");

            switch (option)
            {
            case 0:
                fileAssetPath = LocateAssetFile(invalidPath);
                break;

            case 1: break;

            case 2:
                fileAssetPath = LocateRootAssetFolder <T>(urdfFileName);
                break;
            }

            assetObject = (T)AssetDatabase.LoadAssetAtPath(fileAssetPath, typeof(T));
            if (assetObject != null)
            {
                return(assetObject);
            }

            ChooseFailureOption(urdfFileName);
            return(null);
        }