/// <summary>
        ///     Returns the button style.
        /// </summary>
        /// <returns>The style.</returns>
        public static GUIStyle ButtonStyle()
        {
            Rect titleRect  = new Rect(INNER_MARGIN, INNER_MARGIN, INNER_WIDTH, LINE_HEIGHT);
            Rect buttonRect = new Rect(titleRect);

            buttonRect.width -= 2 * INNER_MARGIN;
            buttonRect.width /= 3.0f;

            GUIStyle buttonStyle = HydraEditorGUIStyles.PictureButtonStyle(buttonRect);

            return(buttonStyle);
        }
Example #2
0
        /// <summary>
        ///     Called to draw the window contents.
        /// </summary>
        protected override void OnGUI()
        {
            base.OnGUI();

            s_KeepOriginalNames = GUILayout.Toggle(s_KeepOriginalNames, "Keep names");

            GUILayout.Space(5);

            s_Prefab = EditorGUILayout.ObjectField("Prefab", s_Prefab, typeof(GameObject), false) as GameObject;

            GUILayout.Space(5);

            HydraEditorLayoutUtils.BeginBox(false);
            {
                s_ScrollPosition = GUILayout.BeginScrollView(s_ScrollPosition);
                {
                    for (int index = 0; index < s_ObjectsToReplace.Count; index++)
                    {
                        GameObject original = s_ObjectsToReplace[index];

                        GUIStyle style = HydraEditorGUIStyles.ArrayElementStyle(index);
                        GUILayout.BeginHorizontal(style);
                        GUILayout.Label(original.name);
                        GUILayout.EndHorizontal();
                    }
                }
                GUILayout.EndScrollView();
            }
            HydraEditorLayoutUtils.EndBox(false);

            GUILayout.Space(5);

            GUILayout.BeginHorizontal();
            {
                bool oldEnabled = GUI.enabled;
                GUI.enabled = s_Prefab != null;

                if (GUILayout.Button("Apply"))
                {
                    Replace();
                }

                GUI.enabled = oldEnabled;
            }
            GUILayout.EndHorizontal();
        }
Example #3
0
        /// <summary>
        ///     Draws the GUID row.
        /// </summary>
        private static void DrawGuidRow(string guid, int index)
        {
            string path = AssetDatabase.GUIDToAssetPath(guid);

            GUIStyle style = HydraEditorGUIStyles.ArrayElementStyle(index);

            Object selected     = Selection.activeObject;
            string selectedPath = AssetDatabase.GetAssetPath(selected);

            if (selectedPath == path)
            {
                style = HydraEditorGUIStyles.arrayElementSelectedStyle;
            }

            GUILayout.BeginHorizontal(style);
            {
                if (!DrawDeleteButton(guid))
                {
                    DrawIcon(guid);

                    if (GUILayout.Button(path, GUI.skin.label))
                    {
                        Object asset = AssetDatabase.LoadAssetAtPath <Object>(path);

                        Selection.activeObject = asset;
                        EditorGUIUtility.PingObject(asset);
                    }

                    List <string> dependencies = s_CachedGuidDependencies[guid];
                    if (dependencies.Count > 0)
                    {
                        string dependenciesLabel = string.Format("{0} dependencies", dependencies.Count);
                        GUILayout.Label(dependenciesLabel, HydraEditorGUIStyles.rightAlignedLabelStyle);
                    }
                }
            }
            GUILayout.EndHorizontal();
        }