void OnRemoveDCCToolButtonClicked(EventBase evt) { Button button = evt.target as Button; if (null == button) { Debug.LogWarning("[MeshSync] Failed to Remove DCC Tool"); return; } DCCToolInfo info = button.userData as DCCToolInfo; if (null == info || string.IsNullOrEmpty(info.AppPath)) { Debug.LogWarning("[MeshSync] Failed to Remove DCC Tool"); return; } MeshSyncEditorSettings settings = MeshSyncEditorSettings.GetOrCreateSettings(); if (settings.RemoveDCCTool(info.AppPath)) { //Delete install info too string installInfoPath = DCCPluginInstallInfo.GetInstallInfoPath(info); if (File.Exists(installInfoPath)) { File.Delete(installInfoPath); } Setup(m_root); } }
//---------------------------------------------------------------------------------------------------------------------- #region Button callbacks void OnAddDCCToolButtonClicked() { string folder = EditorUtility.OpenFolderPanel("Add DCC Tool", m_lastOpenedFolder, ""); if (string.IsNullOrEmpty(folder)) { return; } m_lastOpenedFolder = folder; //Find the path to the actual app DCCToolType lastDCCToolType = DCCToolType.AUTODESK_MAYA; DCCToolInfo dccToolInfo = null; for (int i = 0; i < (int)(DCCToolType.NUM_DCC_TOOL_TYPES) && null == dccToolInfo; ++i) { lastDCCToolType = (DCCToolType)(i); dccToolInfo = DCCFinderUtility.FindDCCToolInDirectory(lastDCCToolType, null, m_lastOpenedFolder); } if (null == dccToolInfo) { EditorUtility.DisplayDialog("MeshSync Project Settings", "No DCC Tool is detected", "Ok"); return; } //Add MeshSyncEditorSettings settings = MeshSyncEditorSettings.GetOrCreateSettings(); if (settings.AddDCCTool(dccToolInfo)) { Setup(m_root); } }
void OnAutoDetectButtonClicked() { MeshSyncEditorSettings settings = MeshSyncEditorSettings.GetOrCreateSettings(); if (settings.AddInstalledDCCTools()) { Setup(m_root); } }
//---------------------------------------------------------------------------------------------------------------------- public void Setup(VisualElement root) { m_root = root; m_root.Clear(); VisualTreeAsset container = UIElementsEditorUtility.LoadVisualTreeAsset( Path.Combine(MeshSyncEditorConstants.PROJECT_SETTINGS_UIELEMENTS_PATH, "DCCToolsSettings_Container") ); VisualTreeAsset dccToolInfoTemplate = UIElementsEditorUtility.LoadVisualTreeAsset( Path.Combine(MeshSyncEditorConstants.PROJECT_SETTINGS_UIELEMENTS_PATH, "DCCToolInfoTemplate") ); TemplateContainer containerInstance = container.CloneTree(); ScrollView scrollView = containerInstance.Query <ScrollView>().First(); //[TODO-sin: 2020-4-24] Auto detect installed DCC tools + check MeshSync status MeshSyncEditorSettings settings = MeshSyncEditorSettings.GetOrCreateSettings(); foreach (var dccToolInfo in settings.GetDCCToolInfos()) { AddDCCToolSettingsContainer(dccToolInfo.Value, scrollView, dccToolInfoTemplate); } //Buttons Button autoDetectButton = containerInstance.Query <Button>("AutoDetectButton").First(); autoDetectButton.clickable.clicked += OnAutoDetectButtonClicked; Button addDCCToolButton = containerInstance.Query <Button>("AddDCCToolButton").First(); addDCCToolButton.clickable.clicked += OnAddDCCToolButtonClicked; //Add the container of this tab to root root.Add(containerInstance); }