private void CopyAssetPropertyToClipboard(string msg, Func <APAsset, string> selector) { if (string.IsNullOrEmpty(msg)) { return; } var decompressedMessage = Encoding.UTF8.GetString(CLZF2.Decompress(Convert.FromBase64String(msg))); var assets = decompressedMessage.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var names = new List <string>(); foreach (var assetId in assets) { var asset = APCache.GetValue(assetId); if (asset != null) { names.Add(selector(asset)); } } TextEditor textEditor = new TextEditor(); textEditor.ReplaceSelection(string.Join("\n", names.ToArray())); textEditor.OnFocus(); textEditor.Copy(); }
private void OpenContainerFolder(string msg, object callback) { Utility.DebugLog(string.Format("OpenFolder Receive: {0}", msg)); if (string.IsNullOrEmpty(msg)) { return; } var decompressedMessage = Encoding.UTF8.GetString(CLZF2.Decompress(Convert.FromBase64String(msg))); var assets = decompressedMessage.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); HashSet <string> folders = new HashSet <string>(); foreach (var item in assets) { var guid = Utility.GetGuidFromAssetId(item); var path = AssetDatabase.GUIDToAssetPath(guid); var folder = Utility.GetContainerFolder(path); Utility.DebugLog(string.Format("OpenFolder: {0}", folder)); if (!string.IsNullOrEmpty(folder)) { folders.Add(folder); } } foreach (var folder in folders) { EditorUtility.RevealInFinder(folder); } }
private void GetIconCache(string message, object callback) { var json = APCache.GetIconCacheJSON(); json = Convert.ToBase64String(CLZF2.Compress(Encoding.UTF8.GetBytes(json))); wrap = new CallbackWrapper(callback); wrap.Send(json); }
private void SelectInHierarchy(string message, object callback) { var decompressedMessage = Encoding.UTF8.GetString(CLZF2.Decompress(Convert.FromBase64String(message))); Utility.DebugLog("Find References in Hierarchy: " + decompressedMessage); var assets = decompressedMessage.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); if (assets.Length == 0) { return; } SearchableEditorWindow hierarchyWindow = null; SearchableEditorWindow[] windows = (SearchableEditorWindow[])Resources.FindObjectsOfTypeAll(typeof(SearchableEditorWindow)); foreach (SearchableEditorWindow window in windows) { if (window.GetType().ToString() == "UnityEditor.SceneHierarchyWindow") { hierarchyWindow = window; break; } } if (hierarchyWindow == null) { return; } var guid = Utility.GetGuidFromAssetId(assets[0]); var instanceId = Utility.GetInstanceIdFromAssetId(assets[0]); if (!string.IsNullOrEmpty(instanceId)) { instanceId += ":"; } string filter = string.Format("ref:{0}\"{1}\"", instanceId, AssetDatabase.GUIDToAssetPath(guid).Substring(7)); var setSearchType = typeof(SearchableEditorWindow).GetMethod("SetSearchFilter", BindingFlags.NonPublic | BindingFlags.Instance); try { setSearchType.Invoke(hierarchyWindow, new object[] { filter, 0, false }); } catch { setSearchType.Invoke(hierarchyWindow, new object[] { filter, 0, false, false }); } }
private void MultiSelect(string paths, object callback) { if (string.IsNullOrEmpty(paths)) { return; } var decompressedIds = Encoding.UTF8.GetString(CLZF2.Decompress(Convert.FromBase64String(paths))); Utility.DebugLog(string.Format("MultiSelect: {0}", decompressedIds)); var assetIds = decompressedIds.Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries); var objects = new UnityEngine.Object[assetIds.Length]; for (int i = 0; i < assetIds.Length; i++) { string id = assetIds[i]; if (Utility.IsSubAsset(id)) { Utility.DebugLog("MultiSelect: Is SubAsset"); var obj = GetAnimationObjectFromModel(id); if (obj != null) { objects[i] = obj; } } else { Utility.DebugLog("MultiSelect: Is Not SubAsset"); objects[i] = AssetDatabase.LoadMainAssetAtPath(AssetDatabase.GUIDToAssetPath(id)); } } if (objects.Length > 0) { Selection.objects = objects; if (Event.current != null) { Event.current.Use(); } ; } }
private string CLZF2_Base64(string s) { return(Convert.ToBase64String(CLZF2.Compress(Encoding.UTF8.GetBytes(s)))); }