Exemplo n.º 1
0
        public virtual void DrawGroup(BatchExpressionGroup group, int deep)
        {
            if (group != null)
            {
                YHEditorTools.PushIndentLevel(deep);

                EditorGUILayout.BeginHorizontal();

                EditorGUILayout.LabelField(group.type.ToString());

                if (GUILayout.Button("+", GUILayout.Width(100)))
                {
                    AddExpressionToGroup(group);
                }

                if (GUILayout.Button("And", GUILayout.Width(100)))
                {
                    AddSubGroupToGroup(group, BatchExpressionGroup.GroupType.And);
                }

                if (GUILayout.Button("Or", GUILayout.Width(100)))
                {
                    AddSubGroupToGroup(group, BatchExpressionGroup.GroupType.Or);
                }

                if (GUILayout.Button("-", GUILayout.Width(100)))
                {
                    RemoveGroup(group);
                }

                EditorGUILayout.EndHorizontal();

                YHEditorTools.PushIndentLevel(deep + 1);
                if (group.expressions.Count > 0)
                {
                    for (int i = 0; i < group.expressions.Count; ++i)
                    {
                        DrawExpression(group.expressions[i]);
                    }
                }

                YHEditorTools.PopIndentLevel();

                if (group.subGroups.Count > 0)
                {
                    for (int i = 0; i < group.subGroups.Count; ++i)
                    {
                        DrawGroup(group.subGroups[i], deep + 1);
                    }
                }

                YHEditorTools.PopIndentLevel();
            }
        }
Exemplo n.º 2
0
        void ShowManualListPanel()
        {
            YHEditorTools.DrawSeparator();

            if (GUILayout.Button("load"))
            {
                m_WrongPathBindings = GetWrongPathBindings();
                m_ToPaths           = new string[m_WrongPathBindings.Count];
            }

            if (m_WrongPathBindings != null && m_WrongPathBindings.Count > 0)
            {
                ShowWrongPaths();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Draw the specified sprite.
        /// </summary>

        public static void DrawSprite(Texture2D tex, Rect rect, Rect outer, Rect inner, Rect uv, Color color, Material mat)
        {
            // Create the texture rectangle that is centered inside rect.
            Rect outerRect = rect;

            outerRect.width  = outer.width;
            outerRect.height = outer.height;

            if (outerRect.width > 0f)
            {
                float f = rect.width / outerRect.width;
                outerRect.width  *= f;
                outerRect.height *= f;
            }

            if (rect.height > outerRect.height)
            {
                outerRect.y += (rect.height - outerRect.height) * 0.5f;
            }
            else if (outerRect.height > rect.height)
            {
                float f = rect.height / outerRect.height;
                outerRect.width  *= f;
                outerRect.height *= f;
            }

            if (rect.width > outerRect.width)
            {
                outerRect.x += (rect.width - outerRect.width) * 0.5f;
            }

            // Draw the background
            DrawTiledTexture(outerRect, YHEditorTools.backdropTexture);

            // Draw the sprite
            GUI.color = color;

            if (mat == null)
            {
                GUI.DrawTextureWithTexCoords(outerRect, tex, uv, true);
            }
            else
            {
                // NOTE: There is an issue in Unity that prevents it from clipping the drawn preview
                // using BeginGroup/EndGroup, and there is no way to specify a UV rect... le'suq.
                UnityEditor.EditorGUI.DrawPreviewTexture(outerRect, tex, mat);
            }

            // Draw the border indicator lines
            GUI.BeginGroup(outerRect);
            {
                tex       = YHEditorTools.contrastTexture;
                GUI.color = Color.white;

                if (inner.xMin != outer.xMin)
                {
                    float x0 = (inner.xMin - outer.xMin) / outer.width * outerRect.width - 1;
                    YHEditorTools.DrawTiledTexture(new Rect(x0, 0f, 1f, outerRect.height), tex);
                }

                if (inner.xMax != outer.xMax)
                {
                    float x1 = (inner.xMax - outer.xMin) / outer.width * outerRect.width - 1;
                    YHEditorTools.DrawTiledTexture(new Rect(x1, 0f, 1f, outerRect.height), tex);
                }

                if (inner.yMin != outer.yMin)
                {
                    float y0 = (inner.yMin - outer.yMin) / outer.height * outerRect.height - 1;
                    YHEditorTools.DrawTiledTexture(new Rect(0f, y0, outerRect.width, 1f), tex);
                }

                if (inner.yMax != outer.yMax)
                {
                    float y1 = (inner.yMax - outer.yMin) / outer.height * outerRect.height - 1;
                    YHEditorTools.DrawTiledTexture(new Rect(0f, y1, outerRect.width, 1f), tex);
                }
            }
            GUI.EndGroup();

            // Draw the lines around the sprite
            Handles.color = Color.black;
            Handles.DrawLine(new Vector3(outerRect.xMin, outerRect.yMin), new Vector3(outerRect.xMin, outerRect.yMax));
            Handles.DrawLine(new Vector3(outerRect.xMax, outerRect.yMin), new Vector3(outerRect.xMax, outerRect.yMax));
            Handles.DrawLine(new Vector3(outerRect.xMin, outerRect.yMin), new Vector3(outerRect.xMax, outerRect.yMin));
            Handles.DrawLine(new Vector3(outerRect.xMin, outerRect.yMax), new Vector3(outerRect.xMax, outerRect.yMax));

            // Sprite size label
            string text = string.Format("Sprite Size: {0}x{1}",
                                        Mathf.RoundToInt(Mathf.Abs(outer.width)),
                                        Mathf.RoundToInt(Mathf.Abs(outer.height)));

            EditorGUI.DropShadowLabel(GUILayoutUtility.GetRect(Screen.width, 18f), text);
        }
Exemplo n.º 4
0
        void OnGUI()
        {
            if (dict == null)
            {
                return;
            }
            mScroll = GUILayout.BeginScrollView(mScroll);

            List <string> list = dict["prefab"];

            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Prefab"))
                {
                    foreach (string item in list)
                    {
                        GameObject go = AssetDatabase.LoadAssetAtPath(item, typeof(GameObject)) as GameObject;
                        EditorGUILayout.ObjectField("Prefab", go, typeof(GameObject), false);
                    }
                }
                list = null;
            }

            list = dict["fbx"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("FBX"))
                {
                    foreach (string item in list)
                    {
                        GameObject go = AssetDatabase.LoadAssetAtPath(item, typeof(GameObject)) as GameObject;
                        EditorGUILayout.ObjectField("FBX", go, typeof(GameObject), false);
                    }
                }
                list = null;
            }

            list = dict["cs"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Script"))
                {
                    foreach (string item in list)
                    {
                        MonoScript go = AssetDatabase.LoadAssetAtPath(item, typeof(MonoScript)) as MonoScript;
                        EditorGUILayout.ObjectField("Script", go, typeof(MonoScript), false);
                    }
                }
                list = null;
            }

            list = dict["texture"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Texture"))
                {
                    foreach (string item in list)
                    {
                        Texture2D go = AssetDatabase.LoadAssetAtPath(item, typeof(Texture2D)) as Texture2D;
                        EditorGUILayout.ObjectField("Texture:" + go.name, go, typeof(Texture2D), false);
                    }
                }
                list = null;
            }

            list = dict["mat"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Material"))
                {
                    foreach (string item in list)
                    {
                        Material go = AssetDatabase.LoadAssetAtPath(item, typeof(Material)) as Material;
                        EditorGUILayout.ObjectField("Material", go, typeof(Material), false);
                    }
                }
                list = null;
            }

            list = dict["shader"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Shader"))
                {
                    foreach (string item in list)
                    {
                        Shader go = AssetDatabase.LoadAssetAtPath(item, typeof(Shader)) as Shader;
                        EditorGUILayout.ObjectField("Shader", go, typeof(Shader), false);
                    }
                }
                list = null;
            }

            list = dict["font"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Font"))
                {
                    foreach (string item in list)
                    {
                        Font go = AssetDatabase.LoadAssetAtPath(item, typeof(Font)) as Font;
                        EditorGUILayout.ObjectField("Font", go, typeof(Font), false);
                    }
                }
                list = null;
            }

            list = dict["anim"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Animation"))
                {
                    foreach (string item in list)
                    {
                        AnimationClip go = AssetDatabase.LoadAssetAtPath(item, typeof(AnimationClip)) as AnimationClip;
                        EditorGUILayout.ObjectField("Animation:", go, typeof(AnimationClip), false);
                    }
                }
                list = null;
            }

            list = dict["animTor"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Animator"))
                {
                    foreach (string item in list)
                    {
                        //Animator go = AssetDatabase.LoadAssetAtPath(item, typeof(Animator)) as Animator;
                        //EditorGUILayout.ObjectField("Animator:", go, typeof(Animator), true);
                        EditorGUILayout.LabelField(item);
                    }
                }
                list = null;
            }

            list = dict["level"];
            if (list != null && list.Count > 0)
            {
                if (YHEditorTools.DrawHeader("Level"))
                {
                    foreach (string item in list)
                    {
                        //SceneView go = AssetDatabase.LoadAssetAtPath(item, typeof(SceneView)) as SceneView;
                        EditorGUILayout.LabelField(item);
                        //SceneView go = AssetDatabase.LoadAssetAtPath(item, typeof(SceneView)) as SceneView;
                        //EditorGUILayout.ObjectField("Animation:" , go, typeof(SceneView), true);
                    }
                }
                list = null;
            }

            GUILayout.EndScrollView();
            //NGUIEditorTools.DrawList("Objects", list.ToArray(), "");
        }
Exemplo n.º 5
0
        public void OnGUI(Rect pos)
        {
            EditorGUILayout.Space();
            GUILayout.BeginHorizontal();
            YHEditorTools.PushLabelWidth(80);
            var newPath = EditorGUILayout.TextField("Search Path", m_SearchPath);

            YHEditorTools.PopLabelWidth();
            if ((newPath != m_SearchPath) && (newPath != string.Empty))
            {
                m_SearchPath = newPath;
            }

            if (GUILayout.Button("Browse", GUILayout.MaxWidth(75f)))
            {
                BrowseForFolder();
            }
            if (GUILayout.Button("Reset", GUILayout.MaxWidth(75f)))
            {
                ResetPathToDefault();
            }
            //if (string.IsNullOrEmpty(m_OutputPath))
            //    m_OutputPath = EditorUserBuildSettings.GetPlatformSettings(EditorUserBuildSettings.activeBuildTarget.ToString(), "AssetBundleOutputPath");
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();

            m_SearchType = (SearchType)EditorGUILayout.EnumPopup("Search Type", m_SearchType, GUILayout.Width(300));
            EditorGUILayout.Space();

            m_Filter = EditorGUILayout.TextField("Filter", m_Filter);
            EditorGUILayout.Space();

            if (m_SearchType == SearchType.Content || m_SearchType == SearchType.Resource)
            {
                GUILayout.BeginHorizontal();
                YHEditorTools.PushLabelWidth(80);
                string className = EditorGUILayout.TextField("Class Name", m_ClassName, GUILayout.MinWidth(360));
                bool   inherit   = EditorGUILayout.Toggle(m_Inherit);
                EditorGUILayout.LabelField("Inherit");

                if (className != m_ClassName)
                {
                    m_ClassName = className;
                    m_Inherit   = inherit;
                    ChangeClassName();
                }

                if (m_Inherit != inherit)
                {
                    m_Inherit = inherit;
                    ChangeInherit();
                }

                YHEditorTools.PopLabelWidth();
                GUILayout.EndHorizontal();

                m_FindConditionView.OnGUI(pos);
            }
            else
            {
                m_FindObject = EditorGUILayout.ObjectField("Object", m_FindObject, typeof(UnityEngine.Object), false);
            }

            if (GUILayout.Button("Search"))
            {
                DoSearch();
            }
        }