/// <summary> /// Convert environment mapped path to real path, if there is a mapping for it. /// For example, if inPath is $HEU_ENVPATH_HDAS/trees/tree1.hda and mapping is /// HEU_ENVPATH_HDAS=C:\temp\hdas\ then the result will be C:\temp\hdas\trees/tree1. /// </summary> /// <param name="inPath"></param> /// <returns></returns> public string ConvertEnvKeyedPathToReal(string inPath) { if(string.IsNullOrEmpty(inPath)) { return inPath; } if(inPath.StartsWith(HEU_Defines.HEU_PATH_KEY_HFS, System.StringComparison.InvariantCulture)) { return HEU_HAPIUtility.GetRealPathFromHFSPath(inPath); } if (_envPathMap == null) { LoadAssetEnvironmentPaths(); } if (_envPathMap != null && inPath.StartsWith(HEU_Defines.HEU_ENVPATH_KEY)) { foreach (KeyValuePair<string, string> pair in _envPathMap) { string key = HEU_Defines.HEU_ENVPATH_KEY + pair.Key; if (inPath.StartsWith(key, System.StringComparison.InvariantCulture)) { inPath = inPath.Replace(key, pair.Value); break; } } } return inPath; }
public static void LoadShelves() { bool bSaveShelf = false; _shelves.Clear(); // Always add the default shelf HEU_Shelf defaultShelf = AddShelf(HEU_Defines.HEU_HENGINE_SHIPPED_SHELF, HEU_Defines.HEU_HENGINE_TOOLS_SHIPPED_FOLDER); defaultShelf._defaultShelf = true; List<string> shelfEntries = HEU_PluginSettings.HEngineToolsShelves; if (shelfEntries == null || shelfEntries.Count == 0) { shelfEntries = new List<string>(); } // Convert shelf path + name to actual shelf objects int numShelves = shelfEntries.Count; for(int i = 0; i < numShelves; i++) { string shelfName = ""; string shelfPath = ""; GetSplitShelfEntry(shelfEntries[i], out shelfName, out shelfPath); // Ignore default shelf because we added it already if(shelfPath.Equals(HEU_Defines.HEU_HENGINE_TOOLS_SHIPPED_FOLDER)) { continue; } if(!string.IsNullOrEmpty(shelfName) && !string.IsNullOrEmpty(shelfPath)) { HEU_Shelf newShelf = new HEU_Shelf(); newShelf._shelfName = shelfName; newShelf._shelfPath = shelfPath; _shelves.Add(newShelf); } else { Debug.LogWarningFormat("Found invalid shelf with entry: {0}", shelfEntries[i]); shelfEntries.RemoveAt(i); i--; bSaveShelf = true; } } foreach(HEU_Shelf shelf in _shelves) { string realShelfPath = HEU_HAPIUtility.GetRealPathFromHFSPath(shelf._shelfPath); if (!HEU_Platform.DoesPathExist(realShelfPath)) { Debug.LogWarningFormat("Shelf path does not exist: {0}", realShelfPath); } else { bool bShelfLoaded = LoadToolsFromDirectory(realShelfPath, out shelf._tools); if (!bShelfLoaded) { Debug.LogWarningFormat("Failed to load shelf {0} at path {1}", shelf._shelfName, realShelfPath); } } } _currentSelectedShelf = HEU_PluginSettings.HEngineShelfSelectedIndex; if (_currentSelectedShelf < 0 || _currentSelectedShelf >= _shelves.Count) { _currentSelectedShelf = 0; HEU_PluginSettings.HEngineShelfSelectedIndex = _currentSelectedShelf; } if (bSaveShelf) { SaveShelf(); } _shelvesLoaded = true; }