Exemplo n.º 1
0
        public void Draw(Rect r, IWindow window)
        {
            bool selected = isSelected();
            var  margin   = 2;
            var  left     = new Rect(r);

            left.width = r.width / 3f;
            var right = new Rect(r);

            right.x    += left.width + margin;
            right.width = r.width * 2f / 3 - margin;

            if (/* FR2_Setting.PingRow && */ Event.current.type == EventType.MouseDown && Event.current.button == 0)
            {
                Rect pingRect = FR2_Setting.PingRow
                                        ? new Rect(0, r.y, r.x + r.width, r.height)
                                        : left;
                if (pingRect.Contains(Event.current.mousePosition))
                {
                    if (Event.current.control || Event.current.command)
                    {
                        if (selected)
                        {
                            FR2_Selection.RemoveSelection(this);
                        }
                        else
                        {
                            FR2_Selection.AppendSelection(this);
                        }

                        if (window != null)
                        {
                            window.Repaint();
                        }
                    }

                    EditorGUIUtility.PingObject(component);
                    //Event.current.Use();
                }
            }


            EditorGUI.ObjectField(left, GUIContent.none, component, typeof(GameObject), true);


            bool   drawPath  = FR2_Setting.GroupMode != FR2_RefDrawer.Mode.Folder;
            float  pathW     = drawPath ? EditorStyles.miniLabel.CalcSize(new GUIContent(scenePath)).x : 0;
            string assetName = component.name;
            // if(usingType!= null && usingType.Count > 0)
            // {
            //  assetName += " -> ";
            //  foreach(var item in usingType)
            //  {
            //      assetName += item + " - ";
            //  }
            //  assetName = assetName.Substring(0, assetName.Length - 3);
            // }
            Color cc = FR2_Cache.Api.setting.SelectedColor;

            var lableRect = new Rect(
                right.x,
                right.y,
                pathW + EditorStyles.boldLabel.CalcSize(new GUIContent(assetName)).x,
                right.height);

            if (selected)
            {
                Color c = GUI.color;
                GUI.color = cc;
                GUI.DrawTexture(lableRect, EditorGUIUtility.whiteTexture);
                GUI.color = c;
            }

            if (drawPath)
            {
                GUI.Label(LeftRect(pathW, ref right), scenePath, EditorStyles.miniLabel);
                right.xMin -= 4f;
                GUI.Label(right, assetName, EditorStyles.boldLabel);
            }
            else
            {
                GUI.Label(right, assetName);
            }


            if (!FR2_Setting.ShowUsedByClassed || usingType == null)
            {
                return;
            }

            float sub = 10;
            var   re  = new Rect(r.x + r.width - sub, r.y, 20, r.height);
            Type  t   = null;

            foreach (string item in usingType)
            {
                string name = item;
                if (!CacheType.TryGetValue(item, out t))
                {
                    t = FR2_Unity.GetType(name);
                    // if (t == null)
                    // {
                    //  continue;
                    // }
                    CacheType.Add(item, t);
                }

                GUIContent content;
                var        width = 0.0f;
                if (!FR2_Asset.cacheImage.TryGetValue(name, out content))
                {
                    if (t == null)
                    {
                        content = new GUIContent(name);
                    }
                    else
                    {
                        Texture text = EditorGUIUtility.ObjectContent(null, t).image;
                        if (text == null)
                        {
                            content = new GUIContent(name);
                        }
                        else
                        {
                            content = new GUIContent(text, name);
                        }
                    }


                    FR2_Asset.cacheImage.Add(name, content);
                }

                if (content.image == null)
                {
                    width = EditorStyles.label.CalcSize(content).x;
                }
                else
                {
                    width = 20;
                }

                re.x    -= width;
                re.width = width;

                GUI.Label(re, content);
                re.x -= margin;                 // margin;
            }


            // var nameW = EditorStyles.boldLabel.CalcSize(new GUIContent(assetName)).x;
        }