/// <summary> /// /// </summary> /// <param name="guid"></param> /// <param name="selectionRect"></param> static void ProjectWindowItemCallback(string guid, Rect selectionRect) { if (!E.i.Enable) { return; } if (s_styles == null) { s_styles = new Styles(); s_styles.lineColor = E.i.lineColor; } if (!IsDetails(selectionRect)) { return; } if (E.i.showLineColor) { DrawBackColor(selectionRect, 0x00); } //showContextMenu( ContextTargetWindow.Project ); float maxx = 50; if (E.i.showExtension) { maxx = ShowExtention(guid, selectionRect); } if (IsAdressableSupport() && IsAdressableAssets(guid)) { var ff = maxx - 20; var rcb = new Rect(ff, selectionRect.y, 16, 16); rcb.y += 2; GUI.Label(rcb, Icon.Get("AssetLabelIcon"), HEditorStyles.iconButton); if (EditorHelper.HasMouseClick(rcb)) { EditorApplication.ExecuteMenuItem("Window/Asset Management/Addressables/Groups"); Event.current.Use(); } } if (E.i.IconClickContext && UnityEditorProjectBrowser.IsTwoColumns()) { var uobj = GUIDUtils.LoadAssetAtGUID <UnityObject>(guid); var r = selectionRect; r.x += 3; r.width = 16; //EditorGUI.DrawRect( r, new Color( 0, 0, 1, 0.5f ) ); if (EditorHelper.HasMouseClick(r)) { var m = new GenericMenu(); m.AddItem(SS._OpenInNewInspector, false, _uobj => EditorHelper.ShowNewInspector(_uobj.ToCast <UnityObject>()), uobj); m.AddItem(S._DuplicateAsset, false, _uobj => EditorHelper.DuplicateAsset <UnityObject>(_uobj.ToCast <UnityObject>()), uobj); if (IsAdressableSupport()) { m.AddSeparator(""); if (IsAdressableAssets(guid)) { m.AddDisabledItem(S._AddtoAddressable); } else { m.AddItem(S._AddtoAddressable, false, _uobj => { UnityAddressableAssetInspectorGUI.SetAaEntry(UnityAddressableAssetSettingsDefaultObject.GetSettings(true), new UnityObject[] { (UnityObject)_uobj }, true); }, uobj); } } #if TEST var path = AssetDatabase.GUIDToAssetPath(guid); if (!AssetDatabase.IsValidFolder(path) && Path.GetExtension(path) == ".mp3") { //var m = new GenericMenu(); m.AddItem("Convert Wav", false, obj => { var proc = new System.Diagnostics.Process(); //proc.WaitForExit(); proc.StartInfo.FileName = Hananoki.Shared.SharedPreference.i.ffmpeg; proc.StartInfo.Arguments = $"-i {path} -y {path.Replace( ".mp3", ".wav" )}"; proc.EnableRaisingEvents = true; //proc.Exited += BuildNspProcess_Exited; proc.Start(); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); return; }, guid); } #endif m.DropDown(r); Event.current.Use(); } } #if false { selectionRect.x -= 12; selectionRect.width = 16; var path = AssetDatabase.GUIDToAssetPath(guid); if (path.GetExtension() == ".prefab") { if (GUI.Button(selectionRect, Icon.Get("Toolbar Plus"), GUIStyle.none)) { GameObject.Instantiate(AssetDatabase.LoadAssetAtPath <GameObject>(path)); Debug.Log("aa"); } } } #endif }
public void LoadProjectIcon() { var ico = GUIDUtils.LoadAssetAtGUID <Texture2D>(Pref.i.iconOpenCSProject); IconCS = ico ?? Icon.Get("dll Script Icon"); }
public static string GetLocalizeName() { return(GUIDUtils.GetAssetPath(Hananoki.Shared.SharedPreference.i.language).FileName()); }
static void DrawContentConfig() { EditorGUI.BeginChangeCheck(); PB.i.enableAssetBundleBuild = HEditorGUILayout.ToggleLeft(S._EnableAssetBundleBuild, PB.i.enableAssetBundleBuild); PB.i.enableOldStyleProjectSettings = HEditorGUILayout.ToggleLeft(S._Usingtheold_styleProjectSettings, PB.i.enableOldStyleProjectSettings); GUILayout.Space(8); PB.i.enableExlusionAssets = HEditorGUILayout.ToggleLeft(S._Enablingassetexclusionatbuildtime, PB.i.enableExlusionAssets); GUILayout.Label(S._ExclusionAssetsList, EditorStyles.boldLabel); if (s_exclusionContents == null) { if (PB.i.exclusionAssets == null) { PB.i.exclusionAssets = new List <PB.ExclusionSets>(); } //foreach(var p in PB.i.exclusionAssets ) { // Debug.Log( GUIDUtils.GetAssetPath( p.GUID ) ); //} s_exclusionContents = PB.i.exclusionAssets.Select(x => GUIDUtils.GetAssetPath(x.GUID)).OrderBy(value => value).Select(x => new GUIContent(x, AssetDatabase.GetCachedIcon(x))).ToArray(); } int removeIndex = -1; using (new GUILayout.VerticalScope(Styles.helpBox)) { for (int i = 0; i < s_exclusionContents.Length; i++) { var s = s_exclusionContents[i]; using (new GUILayout.HorizontalScope()) { GUILayout.Label(EditorHelper.TempContent(""), GUILayout.ExpandWidth(true), GUILayout.Height(18)); } var rc = GUILayoutUtility.GetLastRect(); GUI.Box(rc, "", Styles.projectBrowserHeaderBgMiddle); GUI.Label(rc, s, Styles.labelAndIcon); rc.x = rc.xMax - 16; rc.width = 16; if (HEditorGUI.IconButton(rc, Styles.iconMinus)) { removeIndex = i; } } GUILayout.FlexibleSpace(); if (0 <= removeIndex) { var findGUID = GUIDUtils.ToGUID(s_exclusionContents[removeIndex].text); var rIndex = PB.i.exclusionAssets.FindIndex(x => x.GUID == findGUID); PB.i.exclusionAssets.RemoveAt(rIndex); s_exclusionContents = null; s_changed = true; s_window?.Repaint(); } } var dropRc = GUILayoutUtility.GetLastRect(); var evt = Event.current; switch (evt.type) { case EventType.DragUpdated: case EventType.DragPerform: if (!dropRc.Contains(evt.mousePosition)) { break; } DragAndDrop.visualMode = DragAndDropVisualMode.Copy; void AddFiles(params string[] paths) { PB.i.exclusionAssets.AddRange(paths.Select(x => new PB.ExclusionSets(GUIDUtils.ToGUID(x), x)).ToArray()); PB.i.exclusionAssets = PB.i.exclusionAssets.Distinct(x => x.GUID).ToList(); PB.Save(); } string[] DirFiles(string path) { return(DirectoryUtils.GetFiles(path.ToCast <string>(), "*", SearchOption.AllDirectories).Where(x => x.Extension() != ".meta").ToArray()); } if (evt.type == EventType.DragPerform) { DragAndDrop.AcceptDrag(); if (DragAndDrop.paths.Length == 1) { if (Directory.Exists(DragAndDrop.paths[0])) { var m = new GenericMenu(); m.AddItem(S._Registerasafolder, false, (context) => { AddFiles(context.ToCast <string>()); }, DragAndDrop.paths[0]); m.AddItem(S._Registeringfilescontainedinafolder, false, (context) => { AddFiles(DirFiles(context.ToCast <string>())); ; }, DragAndDrop.paths[0]); m.DropDown(); } else { AddFiles(DragAndDrop.paths); } } else { bool dirChekc = false; foreach (var s in DragAndDrop.paths) { if (Directory.Exists(s)) { dirChekc = true; break; } } if (dirChekc) { var m = new GenericMenu(); m.AddItem(S._Registerasafolder, false, (context) => { AddFiles(context.ToCast <string[]>()); }, DragAndDrop.paths); m.AddItem(S._Registeringfilescontainedinafolder, false, (context) => { foreach (var s in context.ToCast <string[]>()) { if (Directory.Exists(s)) { AddFiles(DirFiles(s)); } else { AddFiles(s); } } }, DragAndDrop.paths); m.DropDown(); } else { AddFiles(DragAndDrop.paths); } } DragAndDrop.activeControlID = 0; s_exclusionContents = null; } s_changed = true; Event.current.Use(); break; } if (EditorGUI.EndChangeCheck()) { s_changed = true; } }