Ejemplo n.º 1
0
        void UpdateText(Texture assetIcon, string assetName)
        {
            var stage = SceneManagement.StageNavigationManager.instance.currentItem;

            if (stage.isMainStage)
            {
                m_StageContent.image = EditorGUIUtility.IconContent("SceneAsset Icon").image;
                m_StageContent.text  = "Scene";
            }
            else
            {
                m_StageContent.image = (Texture2D)AssetDatabase.GetCachedIcon(stage.prefabAssetPath);
                m_StageContent.text  = stage.displayName;
            }

            m_InstanceContent.image = assetIcon;
            m_InstanceContent.text  = assetName;

            m_RevertAllContent.text    = Styles.revertAllContent.text;
            m_RevertAllContent.tooltip = Styles.revertAllContent.tooltip;

            var applyAllContent = Styles.applyAllContent;

            if (stage.isPrefabStage && PrefabUtility.IsPartOfVariantPrefab(AssetDatabase.LoadAssetAtPath <Object>(stage.prefabAssetPath)))
            {
                applyAllContent = Styles.applyAllToBaseContent;
            }

            m_ApplyAllContent.text    = applyAllContent.text;
            m_ApplyAllContent.tooltip = string.Format(applyAllContent.tooltip, assetName);
        }
        void UpdateText(Texture assetIcon, string assetName)
        {
            var stage = SceneManagement.StageNavigationManager.instance.currentStage;

            if (stage is MainStage)
            {
                m_StageContent.image = EditorGUIUtility.IconContent("SceneAsset Icon").image;
                m_StageContent.text  = "Scene";
            }
            else if (stage is PrefabStage)
            {
                m_StageContent.image = (Texture2D)AssetDatabase.GetCachedIcon(stage.assetPath);
                m_StageContent.text  = System.IO.Path.GetFileNameWithoutExtension(stage.assetPath);
            }

            m_InstanceContent.image = assetIcon;
            m_InstanceContent.text  = assetName;

            m_RevertAllContent      = Styles.revertAllContent;
            m_RevertSelectedContent = Styles.revertSelectedContent;

            m_ButtonWidth = k_ButtonWidth;
            var applyAllContent      = new GUIContent(Styles.applyAllContent);
            var applySelectedContent = Styles.applySelectedContent;

            if (stage is PrefabStage && PrefabUtility.IsPartOfVariantPrefab(AssetDatabase.LoadAssetAtPath <Object>(stage.assetPath)))
            {
                m_ButtonWidth        = k_ButtonWidthVariant;
                applyAllContent      = Styles.applyAllToBaseContent;
                applySelectedContent = Styles.applySelectedToBaseContent;
            }

            if (!m_HasApplicableOverrides)
            {
                applyAllContent.tooltip = Styles.nonApplicableTooltip;
            }

            m_ApplyAllContent              = new GUIContent(applyAllContent.text, string.Format(applyAllContent.tooltip, assetName));
            m_ApplySelectedContent.text    = applySelectedContent.text;
            m_ApplySelectedContent.tooltip = string.Format(applySelectedContent.tooltip, assetName);
        }