예제 #1
0
        protected override void Draw(Rect r)
        {
            var drawR = r;

            drawR.xMin -= 16f;
            asset.Draw(drawR, false, false);

            var bRect = r;

            bRect.xMin += bRect.width - 50f;
            if (GUI.Button(bRect, "Use", EditorStyles.miniButton))
            {
                EditorGUIUtility.systemCopyBuffer = asset.guid;
                Selection.objects = (parent as FR2_DuplicateFolder).children.Select(
                    a => FR2_Unity.LoadAssetAtPath <Object>(((FR2_DuplicateAsset)a).asset.assetPath)
                    ).ToArray();
                FR2_Export.MergeDuplicate();
            }

            //if (GUI.Button(bRect, "Remove Others", EditorStyles.miniButton))
            //{
            //    EditorGUIUtility.systemCopyBuffer = asset.guid;
            //    Selection.objects = (parent as FR2_DuplicateFolder).children.Select(
            //        a => FR2_Unity.LoadAssetAtPath<Object>(((FR2_DuplicateAsset)a).asset.assetPath)
            //    ).ToArray();
            //    FR2_Export.MergeDuplicate();
            //}
        }
예제 #2
0
        private void DrawGUIDs()
        {
            var ids  = FR2_Unity.Selection_AssetGUIDs;
            var objs = Selection.objects;

            GUILayout.Label("GUID to Object", EditorStyles.boldLabel);
            GUILayout.BeginHorizontal();
            {
                var guid = EditorGUILayout.TextField(tempGUID ?? string.Empty);
                EditorGUILayout.ObjectField(tempObject, typeof(Object), false, GUILayout.Width(120f));

                if (GUILayout.Button("Paste", EditorStyles.miniButton, GUILayout.Width(70f)))
                {
                    guid = EditorGUIUtility.systemCopyBuffer;
                }

                if (guid != tempGUID && !string.IsNullOrEmpty(guid))
                {
                    tempGUID = guid;

                    tempObject = FR2_Unity.LoadAssetAtPath <Object>
                                 (
                        AssetDatabase.GUIDToAssetPath(tempGUID)
                                 );
                }
            }
            GUILayout.EndHorizontal();
            GUILayout.Space(10f);
            //GUILayout.Label("Selection", EditorStyles.boldLabel);
            if (ids.Length == objs.Length)
            {
                scrollPos = GUILayout.BeginScrollView(scrollPos);
                {
                    for (var i = 0; i < ids.Length; i++)
                    {
                        GUILayout.BeginHorizontal();
                        {
                            EditorGUILayout.ObjectField(objs[i], typeof(Object), false);
                            var idi = ids[i];
                            GUILayout.TextField(idi, GUILayout.Width(240f));
                            if (GUILayout.Button("Copy", EditorStyles.miniButton, GUILayout.Width(50f)))
                            {
                                EditorGUIUtility.systemCopyBuffer = idi;
                                //Debug.Log(EditorGUIUtility.systemCopyBuffer);
                            }
                        }
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndScrollView();
            }

            GUILayout.FlexibleSpace();
            if (GUILayout.Button("Merge Selection"))
            {
                FR2_Export.MergeDuplicate();
            }
        }
예제 #3
0
        internal void AddToSelection()
        {
            var list = Selection.objects.ToList();
            var obj  = FR2_Unity.LoadAssetAtPath <Object>(assetPath);

            if (!list.Contains(obj))
            {
                list.Add(obj);
                Selection.objects = list.ToArray();
            }
        }
예제 #4
0
        //-------------------------- UTILS ---------------------

        internal static void AddToDict(Dictionary <string, Object> dict, params FR2_Asset[] list)
        {
            for (var j = 0; j < list.Length; j++)
            {
                string guid = list[j].guid;
                if (!dict.ContainsKey(guid))
                {
                    string assetPath = AssetDatabase.GUIDToAssetPath(guid);
                    dict.Add(guid, FR2_Unity.LoadAssetAtPath <Object>(assetPath));
                }
            }
        }
예제 #5
0
 private static bool RestoreCacheFromPath(string path, bool savePrefs, bool writeFile)
 {
     if (string.IsNullOrEmpty(path))
     {
         return(false);
     }
     _cache = FR2_Unity.LoadAssetAtPath <FR2_Cache>(path);
     if (_cache != null)
     {
         FoundCache(savePrefs, writeFile);
     }
     return(_cache != null);
 }
예제 #6
0
 private static List <Object> GetSelectionDependencies()
 {
     if (!FR2_Cache.isReady)
     {
         Debug.LogWarning("FR2 cache not yet ready, please open Window > FR2_Window !");
         return(null);
     }
     return(FR2_Cache.FindUsage(FR2_Unity.Selection_AssetGUIDs).Select(
                guid =>
     {
         var assetPath = AssetDatabase.GUIDToAssetPath(guid);
         return FR2_Unity.LoadAssetAtPath <Object>(assetPath);
     }
                ).ToList());
 }
예제 #7
0
        public override void OnSelectionChange()
        {
            Repaint();

            isNoticeIgnore = false;
            if (!FR2_Cache.isReady)
            {
                return;
            }

            if (lockSelection)
            {
                return;
            }

            if (focusedWindow == null)
            {
                return;
            }

            if (SceneUsesDrawer == null)
            {
                InitIfNeeded();
            }

            if (UsesDrawer == null)
            {
                InitIfNeeded();
            }

            ids = FR2_Unity.Selection_AssetGUIDs;

            //ignore selection on asset when selected any object in scene
            if (Selection.gameObjects.Length > 0 && !FR2_Unity.IsInAsset(Selection.gameObjects[0]))
            {
                ids = new string[0];
            }

            level = 0;
            if (IsFocusingSceneToAsset)
            {
                SceneToAssetDrawer.Reset(Selection.gameObjects, true, true);
            }

            if (IsFocusingUses)
            {
                UsesDrawer.Reset(ids, true);
            }

            if (IsFocusingUsedBy)
            {
                UsedByDrawer.Reset(ids, false);
            }

            if (IsFocusingSceneInScene)
            {
                RefSceneInScene.ResetSceneInScene(Selection.gameObjects);
            }

            if (IsFocusingUses)
            {
                SceneUsesDrawer.ResetSceneUseSceneObjects(Selection.gameObjects);
            }

            if (IsFocusingFindInScene)
            {
                RefInScene.Reset(ids, this as IWindow);
            }

            if (IsFocusingGUIDs)
            {
                objs = new Object[ids.Length];
                for (var i = 0; i < ids.Length; i++)
                {
                    objs[i] = FR2_Unity.LoadAssetAtPath <Object>
                              (
                        AssetDatabase.GUIDToAssetPath(ids[i])
                              );
                }
            }


            if (FR2_SceneCache.Api.Dirty && !Application.isPlaying)
            {
                FR2_SceneCache.Api.refreshCache(this);
            }

            EditorApplication.delayCall -= Repaint;
            EditorApplication.delayCall += Repaint;
        }
예제 #8
0
        private void DrawAsset(Rect r, string guid)
        {
            FR2_Ref rf;

            if (!refs.TryGetValue(guid, out rf))
            {
                return;
            }

            if (rf.depth == 1)             //mode != Mode.Dependency &&
            {
                Color c = GUI.color;
                GUI.color = Color.blue;
                GUI.DrawTexture(new Rect(r.x - 4f, r.y + 2f, 2f, 2f), EditorGUIUtility.whiteTexture);
                GUI.color = c;
            }

            rf.asset.Draw(r, false, FR2_Setting.GroupMode != FR2_RefDrawer.Mode.Folder, window, false);

            Texture tex = AssetDatabase.GetCachedIcon(rf.asset.assetPath);

            if (tex == null)
            {
                return;
            }

            Rect drawR = r;

            drawR.x       = drawR.x + drawR.width - 60f;       // (groupDrawer.TreeNoScroll() ? 60f : 70f) ;
            drawR.width   = 40f;
            drawR.y      += 1;
            drawR.height -= 2;

            if (GUI.Button(drawR, "Use", EditorStyles.miniButton))
            {
                if (FR2_Export.IsMergeProcessing)
                {
                    Debug.LogWarning("Previous merge is processing");
                }
                else
                {
                    AssetDatabase.SaveAssets();
                    EditorGUIUtility.systemCopyBuffer = rf.asset.guid;
                    EditorGUIUtility.systemCopyBuffer = rf.asset.guid;
                    // Debug.Log("guid: " + rf.asset.guid + "  systemCopyBuffer " + EditorGUIUtility.systemCopyBuffer);
                    int index = rf.index;
                    Selection.objects = list.Where(x => x.index == index)
                                        .Select(x => FR2_Unity.LoadAssetAtPath <Object>(x.asset.assetPath)).ToArray();
                    FR2_Export.MergeDuplicate();
                }
            }

            if (rf.asset.UsageCount() > 0)
            {
                return;
            }

            drawR.x    -= 25;
            drawR.width = 20;
            if (wasPreDelete(guid))
            {
                Color col = GUI.color;
                GUI.color = Color.red;
                if (GUI.Button(drawR, "X", EditorStyles.miniButton))
                {
                    guidPressDelete = null;
                    AssetDatabase.DeleteAsset(rf.asset.assetPath);
                }

                GUI.color          = col;
                window.WillRepaint = true;
            }
            else
            {
                if (GUI.Button(drawR, "X", EditorStyles.miniButton))
                {
                    guidPressDelete    = guid;
                    TimePressDelete    = Time.realtimeSinceStartup;
                    window.WillRepaint = true;
                }
            }
        }