private void OnGUI() { textFieldGUIStyle = new GUIStyle(GUI.skin.textField) { alignment = TextAnchor.MiddleRight }; GUILayout.Space(8); GUILayout.TextField(sourcePath, textFieldGUIStyle); if (GUILayout.Button("Choose Source Path")) { sourcePath = EditorUtility.OpenFolderPanel("Source Path", Application.dataPath, string.Empty).ToBackSlashes(); } GUILayout.Space(10); GUILayout.TextField(targetPath, textFieldGUIStyle); if (GUILayout.Button("Choose Target Path")) { targetPath = EditorUtility.OpenFolderPanel("Target Path", targetPath, string.Empty).ToBackSlashes(); } GUILayout.Space(8); if (GUILayout.Button("Import Package")) { if (string.IsNullOrEmpty(sourcePath) || string.IsNullOrEmpty(targetPath)) { Debug.Log("Please specify a path"); } else if (targetPath.Contains(sourcePath)) { Debug.LogWarning("Holy Infinite Loop Batman! You should probably consider choosing a better path.\n" + "Preferably one that doesn't create rips in the fabric of time and digital space."); } else { if (window != null) { window.Close(); } MixedRealityPreferences.AutoLoadSymbolicLinks = true; SymbolicLinker.AddLink(sourcePath, targetPath); EditorUtility.SetDirty(SymbolicLinker.Settings); AssetDatabase.SaveAssets(); if (!EditorApplication.isUpdating) { AssetDatabase.Refresh(); } } } }
private static void DisableSymbolicLink() { var guids = Selection.assetGUIDs; if (guids == null || guids.Length != 1) { return; } var path = AssetDatabase.GUIDToAssetPath(guids[0]); path = Path.GetFullPath(path).ToBackSlashes(); var symbolicLink = SymbolicLinker.Settings.SymbolicLinks.Find(link => $"{SymbolicLinker.ProjectRoot}{link.TargetRelativePath}" == path); if (symbolicLink == null) { return; } switch (EditorUtility.DisplayDialogComplex("Delete this Symbolically linked path?", path, "Disable Link", "Delete Link", "Cancel")) { case 0: SymbolicLinker.DisableLink(symbolicLink.TargetRelativePath); break; case 1: SymbolicLinker.RemoveLink(symbolicLink.SourceRelativePath, symbolicLink.TargetRelativePath); break; } EditorUtility.SetDirty(SymbolicLinker.Settings); AssetDatabase.SaveAssets(); if (!EditorApplication.isUpdating) { AssetDatabase.Refresh(); } }