Exemplo n.º 1
0
        void DrawObjectFieldGUI(ref string name, ref UnityObject scene)
        {
            GUILayout.BeginVertical(GUILayout.Width(colWidth));
            {
                var lastVal = scene;
#if !(Unity3 || Unity4_0To4_2)
                GUILayout.BeginHorizontal();
                name = GUILayout.TextField(name, GUILayout.Width(EditorGUIUtility.labelWidth));
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(SceneAsset), true);
#else
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(UnityObject), true);
#endif
                GUILayout.EndHorizontal();
#else
                scene = EditorGUILayoutExt.ObjectField(name, scene, typeof(UnityObject), true);
#endif
                if (scene != lastVal)
                {
                    // ReSharper disable once ConvertIfStatementToConditionalTernaryExpression
                    if (scene)
                    {
                        name = scene.name;
                    }
                    else
                    {
                        name = string.Empty;
                    }
                }
            }
            GUILayout.EndVertical();
        }
Exemplo n.º 2
0
        void DrawObjectFieldGUI(ref string name, ref UnityObject scene)
        {
            GUILayout.BeginVertical(GUILayout.Width(colWidth));
            {
#if !(Unity3 || Unity4_0To4_2)
                GUILayout.BeginHorizontal();
                name = GUILayout.TextField(name, GUILayout.Width(EditorGUIUtility.labelWidth));
#if UNITY_5_3 || UNITY_5_3_OR_NEWER
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(SceneAsset), true);
#else
                scene = EditorGUILayoutExt.ObjectField(scene, typeof(UnityObject), true);
#endif
                GUILayout.EndHorizontal();
#else
                scene = EditorGUILayoutExt.ObjectField(name, scene, typeof(UnityObject), true);
#endif
            }
            GUILayout.EndVertical();
        }
Exemplo n.º 3
0
        // ReSharper disable once UnusedMember.Local
        void OnGUI()
        {
            //Ctrl + w to close
            if (Event.current.Equals(Event.KeyboardEvent("^w")))
            {
                Close();
                GUIUtility.ExitGUI();
            }

            if (obj == null)
            {
                obj        = viewObject;
                viewObject = null;
            }

            obj = EditorGUILayoutExt.ObjectField("Object", obj, typeof(Object), true);

            GUI.enabled = obj != null;

            fullPath         = EditorGUILayout.Toggle("Show Full Paths", fullPath);
            showDepth        = EditorGUILayout.Toggle("Show Depths", showDepth);
            showType         = EditorGUILayout.Toggle("Show Types", showType);
            showStringArrays = EditorGUILayout.Toggle("Show String Arrays", showStringArrays);

#if !(Unity3 || Unity4_0To4_2)
            EditorGUIUtility.labelWidth = fullPath ? 250 : 150;
#endif

            if (GUILayout.Button("Refresh"))
            {
                so = new SerializedObject(obj);
            }

            if (GUILayout.Button("Print"))
            {
                var it   = so.GetIterator();
                var next = it.Next(true);
                while (next)
                {
                    if (it.name == "m_Script")
                    {
                        Debug.Log("Script array hidden for performance reasons");
                        var depth = it.depth;
                        Debug.Log(it.name);
                        while ((next = it.Next(true)) && it.depth > depth || it.name == "Array")
                        {
                        }
                    }

                    if (!next)
                    {
                        break;
                    }

                    Debug.Log(it.depth + " - " + it.propertyPath + " (" + it.propertyType + ")");

                    next = it.Next(true);
                }
            }

            if (obj != null)
            {
                scroll = GUILayout.BeginScrollView(scroll);
                if (so == null || so.targetObject != obj)
                {
                    so = new SerializedObject(obj);
                }

                var count    = 0;
                var iterator = so.GetIterator();
                var hasNext  = iterator.Next(true);
                while (hasNext)
                {
                    if (iterator.name == "m_Script")
                    {
                        GUI.enabled = false;
                        GUILayout.Label("Script array hidden for performance reasons");
                        GUI.enabled = true;
                        var depth = iterator.depth;
                        while ((hasNext = iterator.Next(true)) && iterator.depth > depth || iterator.name == "Array")
                        {
                        }
                    }

                    if (!hasNext)
                    {
                        break;
                    }

                    GUILayout.BeginHorizontal();
                    GUILayout.Space(Util.tabSize * iterator.depth);

                    if (showDepth)
                    {
                        GUILayout.Label(iterator.depth + "", GUILayout.Width(10));
                    }

                    if (showType)
                    {
                        GUILayout.Label(iterator.propertyType + "", GUILayout.Width(50));
                    }
                    try {
#if !UNITY_3_4 && !UNITY_3_3 && !UNITY_3_2 && !UNITY_3_1 && !UNITY_3_0_0 && !UNITY_3_0
                        if (fullPath)
                        {
                            EditorGUILayout.PropertyField(iterator, new GUIContent(iterator.propertyPath), false);
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(iterator, false);
                        }
#else
                        if (fullPath)
                        {
                            EditorGUILayout.PropertyField(iterator, new GUIContent(iterator.propertyPath));
                        }
                        else
                        {
                            EditorGUILayout.PropertyField(iterator);
                        }
#endif
                    } catch {
                        /* ignored */
                    }
                    GUILayout.EndHorizontal();

                    hasNext = iterator.Next(iterator.isExpanded);

                    if (count++ > MaxCount)
                    {
                        break;
                    }
                }
                GUILayout.EndScrollView();

                so.ApplyModifiedProperties();
            }
        }
Exemplo n.º 4
0
        // ReSharper disable once UnusedMember.Local
        void OnGUI()
        {
            //Ctrl + w to close
            if (Event.current.Equals(Event.KeyboardEvent("^w")))
            {
                Close();
                GUIUtility.ExitGUI();
            }

            const string label   = "Frame Time (ms)";
            const string tooltip = "Time between yields when processing big scenes. Bigger is faster, but will slow down the UI";

            frameTime = EditorGUILayout.IntSlider(new GUIContent(label, tooltip), frameTime, 1, 1000);
            UniMergeWindow.frameTimeTicks = frameTime * 10000;
            GUILayout.Label("To change these values, set them in UniMergeConfig.cs");
            EditorGUILayout.LabelField("Default Skin", DefaultGuiSkinFilename);
            EditorGUILayout.LabelField("Dark Skin", DarkGuiSkinFilename);
            EditorGUILayout.LabelField("Plugin Path", DefaultPath);
            EditorGUILayout.LabelField("List Style Name", ListStyleName);
            EditorGUILayout.LabelField("List Alt Style Name", ListAltStyleName);
            EditorGUILayout.LabelField("Conflict Suffix", ConflictSuffix);

            GUILayout.Label(new GUIContent(
                                "Note: In order to save your changes you must make\nsome change to the skin in the editor.",
                                "This is because modifying the skin via script doesn't set it \"dirty\""));

            scroll = EditorGUILayout.BeginScrollView(scroll);
            var defaultSkin =
                AssetDatabase.LoadAssetAtPath(DefaultPath + "/" + DefaultGuiSkinFilename, typeof(GUISkin)) as GUISkin;

            if (defaultSkin)
            {
                if (defaultSkin.customStyles.Length < 4)
                {
                    var newStyles = new GUIStyle[4];
                    defaultSkin.customStyles.CopyTo(newStyles, 0);
                    defaultSkin.customStyles = newStyles;
                }
                for (var i = 0; i < defaultSkin.customStyles.Length; i++)
                {
                    if (defaultSkin.customStyles[i] == null)
                    {
                        defaultSkin.customStyles[i] = new GUIStyle();
                    }
                }
                defaultSkin.customStyles[0].name = ListStyleName;
                defaultSkin.customStyles[1].name = ListAltStyleName;
                defaultSkin.customStyles[2].name = ListStyleName + ConflictSuffix;
                defaultSkin.customStyles[3].name = ListAltStyleName + ConflictSuffix;
                GUILayout.Label("Default Skin background colors");
                defaultSkin.customStyles[0].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName,
                                                                                                          defaultSkin.customStyles[0].normal.background, typeof(Texture2D), false);
                defaultSkin.customStyles[1].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName,
                                                                                                          defaultSkin.customStyles[1].normal.background, typeof(Texture2D), false);
                defaultSkin.customStyles[2].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName + ConflictSuffix,
                                                              defaultSkin.customStyles[2].normal.background, typeof(Texture2D), false);
                defaultSkin.customStyles[3].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName + ConflictSuffix,
                                                              defaultSkin.customStyles[3].normal.background, typeof(Texture2D), false);
            }
            else
            {
                GUILayout.Label("<color=red>Oops! No Light Skin found!</color>");
            }

            var darkSkin = AssetDatabase.LoadAssetAtPath(DefaultPath + "/" + DarkGuiSkinFilename, typeof(GUISkin)) as GUISkin;

            if (darkSkin)
            {
                if (darkSkin.customStyles.Length < 4)
                {
                    var newStyles = new GUIStyle[4];
                    darkSkin.customStyles.CopyTo(newStyles, 0);
                    darkSkin.customStyles = newStyles;
                }
                for (var i = 0; i < darkSkin.customStyles.Length; i++)
                {
                    if (darkSkin.customStyles[i] == null)
                    {
                        darkSkin.customStyles[i] = new GUIStyle();
                    }
                }
                darkSkin.customStyles[0].name = ListStyleName;
                darkSkin.customStyles[1].name = ListAltStyleName;
                darkSkin.customStyles[2].name = ListStyleName + ConflictSuffix;
                darkSkin.customStyles[3].name = ListAltStyleName + ConflictSuffix;
                GUILayout.Label("Dark Skin background colors");
                darkSkin.customStyles[0].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName,
                                                                                                       darkSkin.customStyles[0].normal.background, typeof(Texture2D), false);
                darkSkin.customStyles[1].normal.background = (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName,
                                                                                                       darkSkin.customStyles[1].normal.background, typeof(Texture2D), false);
                darkSkin.customStyles[2].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListStyleName + ConflictSuffix,
                                                              darkSkin.customStyles[2].normal.background, typeof(Texture2D), false);
                darkSkin.customStyles[3].normal.background =
                    (Texture2D)EditorGUILayoutExt.ObjectField(ListAltStyleName + ConflictSuffix,
                                                              darkSkin.customStyles[3].normal.background, typeof(Texture2D), false);
            }
            else
            {
                GUILayout.Label("<color=red>Oops! No Dark Skin found!</color>");
            }
            EditorGUILayout.EndScrollView();
        }
Exemplo n.º 5
0
        // ReSharper disable once UnusedMember.Local
        void OnGUI()
        {
            if (InitGUI())
            {
                return;
            }

            /*
             * BEGIN GUI
             */

            var root = this.root;

            GUILayout.BeginHorizontal();
            {
                /*
                 * Options
                 */
                GUILayout.BeginVertical();
                {
                    const string tooltip = "When enabled, copying GameObjects or Components will search for references"
                                           + " to them and try to set them.  Disable if you do not want this behavior or if the window "
                                           + "locks up on copy (too many objects)";
                    deepCopy = EditorGUILayout.Toggle(new GUIContent("Deep Copy", tooltip), deepCopy);
                }

                {
                    const string tooltip = "When enabled, non-obvious events (like deep copy reference setting) will be logged";
                    log = EditorGUILayout.Toggle(new GUIContent("Log", tooltip), log);
                }

                {
                    const string tooltip = "When disabled, attributes will not be included in comparison algorithm."
                                           + "  To choose which components are included, use the drop-downs to the right.";
                    compareAttrs = EditorGUILayout.Toggle(new GUIContent("Compare Attributes", tooltip), compareAttrs);
                }

                GUI.enabled = !IsUpdating();
                if (GUILayout.Button("Expand Differences"))
                {
                    updateCount    = 0;
                    totalUpdateNum = GameObjectHelper.GetCount(false, root);
                    updateType     = RefreshType.Expanding;
                    update         = root.ExpandDiffs();
                }

                //GUILayout.BeginHorizontal();
                //if (GUILayout.Button("Prev Difference")) {
                //	PrevDifference();
                //}
                //if (GUILayout.Button("Next Difference")) {
                //	NextDifference();
                //}
                //GUILayout.EndHorizontal();

                if (GUILayout.Button("Refresh"))
                {
                    update = root.BubbleRefresh();
                }

                GUI.enabled = true;

                DrawRowHeight();

                GUILayout.Space(10);                 //Padding between controls and merge space
                GUILayout.EndVertical();

                /*
                 * Comparison Filters
                 */
                GUILayout.BeginVertical();
                GUILayout.BeginHorizontal();

#if !Unity3
                GUILayout.FlexibleSpace();
#endif

#if Unity3 //TODO: Better masking for U3
                GUILayout.BeginVertical();
                GUILayout.Label("Enter a list of component types to exclude, separated by commas");
                filters = EditorGUILayout.TextField("Filters", filters);
                if (filters != lastFilters)
                {
                    ParseFilters();
                }
                lastFilters = filters;
                string filt = "Filtering: ";
                if (filterTypes.Count > 0)
                {
                    foreach (System.Type bad in filterTypes)
                    {
                        filt += bad.Name + ", ";
                    }
                    GUILayout.Label(filt.Substring(0, filt.Length - 2));
                }
                string err = "Sorry, the following types are invalid: ";
                if (badTypes.Count > 0)
                {
                    foreach (string bad in badTypes)
                    {
                        err += bad + ", ";
                    }
                    GUILayout.Label(err.Substring(0, err.Length - 2));
                }
                string cerr = "Sorry, the following types aren't components: ";
                if (notComponents.Count > 0)
                {
                    foreach (string bad in notComponents)
                    {
                        cerr += bad + ", ";
                    }
                    GUILayout.Label(cerr.Substring(0, cerr.Length - 2));
                }
                GUILayout.EndVertical();
#else
                GUILayout.Label(new GUIContent("Comparison Filters",
                                               "Select which components should be included in"
                                               + " the comparison. You can't filter more"
                                               + " than 31 things :("));
                if (componentTypeStrings != null)
                {
                    var mask = typeMask;
                    for (var i = 0; i < componentTypeStrings.Length; i++)
                    {
                        mask[i] = EditorGUILayout.MaskField(mask[i], componentTypeStrings[i], Width75);
                        if (i % 3 == 2)
                        {
                            GUILayout.EndHorizontal();
                            GUILayout.BeginHorizontal();
                            GUILayout.FlexibleSpace();
                        }
                    }
                }
#endif
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
            }
            GUILayout.EndHorizontal();
            GUILayout.BeginHorizontal();
            var colWdithOption = GUILayout.Width(colWidth);
            var mine           = root.mine;
            var theirs         = root.theirs;
            var lastVal        = mine;
            GUILayout.BeginVertical(colWdithOption);
#if !(Unity3 || Unity4_0To4_2)
            GUILayout.BeginHorizontal();
            var labelWidthOption = GUILayout.Width(EditorGUIUtility.labelWidth);
            mineName = GUILayout.TextField(mineName, labelWidthOption);
            mine     = (GameObject)EditorGUILayoutExt.ObjectField(mine, typeof(GameObject), true);
            GUILayout.EndHorizontal();
#else
            mine = (GameObject)EditorGUILayoutExt.ObjectField(mineName, mine, typeof(GameObject), true);
#endif
            if (mine != lastVal)
            {
                root.SetGameObjects(mine, theirs);
                if (!blockRefresh)
                {
                    update = Refresh();
                }
            }

            lastVal = theirs;
            GUILayout.EndVertical();
            GUILayout.Space(UniMergeConfig.DoubleMidWidth);
            GUILayout.BeginVertical(colWdithOption);
#if !(Unity3 || Unity4_0To4_2)
            GUILayout.BeginHorizontal();
            theirName = GUILayout.TextField(theirName, labelWidthOption);
            theirs    = (GameObject)EditorGUILayoutExt.ObjectField(theirs, typeof(GameObject), true);
            GUILayout.EndHorizontal();
#else
            theirs = (GameObject)EditorGUILayoutExt.ObjectField(theirName, theirs, typeof(GameObject), true);
#endif
            if (theirs != lastVal)
            {
                root.SetGameObjects(mine, theirs);
                if (!blockRefresh)
                {
                    update = Refresh();
                }
            }

            GUILayout.EndVertical();
            GUILayout.EndHorizontal();

#if !(Unity3 || Unity4_0To4_2)
            EditorGUIUtility.labelWidth = 75;             //Make labels just a bit tighter for compactness
#endif
            if (mine && theirs)
            {
                CustomScroll(draw);
            }

            ProgressBar();
        }