Example #1
0
        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);
            }
        }
Example #2
0
//----------------------------------------------------------------------------------------------------------------------

        #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);
            }
        }
Example #3
0
        void OnAutoDetectButtonClicked()
        {
            MeshSyncEditorSettings settings = MeshSyncEditorSettings.GetOrCreateSettings();

            if (settings.AddInstalledDCCTools())
            {
                Setup(m_root);
            }
        }
Example #4
0
//----------------------------------------------------------------------------------------------------------------------

    #region File Load/Save for Serialization/deserialization
    static MeshSyncEditorSettings LoadEditorSettings() {
        string path = MESHSYNC_EDITOR_SETTINGS_PATH;
        if (!File.Exists(path)) {
            return null;
        }
        
        string json = File.ReadAllText(path);
        MeshSyncEditorSettings settings = JsonUtility.FromJson<MeshSyncEditorSettings>(json);
        
        return settings;
    }
Example #5
0
    internal static MeshSyncEditorSettings GetOrCreateSettings() {
        MeshSyncEditorSettings settings = LoadEditorSettings();
        if (null != settings) {
            return settings;
        }

        settings = new MeshSyncEditorSettings();
        settings.AddInstalledDCCTools();
        settings.SaveEditorSettings();
        return settings;
            
    }
Example #6
0
//----------------------------------------------------------------------------------------------------------------------
        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);
        }