Beispiel #1
0
        internal virtual void OnHeaderControlsGUI()
        {
            GUILayoutUtility.GetRect(10f, 10f, 16f, 16f, EditorStyles.layerMaskField);
            GUILayout.FlexibleSpace();
            bool flag = true;

            if (!(this is AssetImporterEditor))
            {
                if (!AssetDatabase.IsMainAsset(this.targets[0]))
                {
                    flag = false;
                }
                AssetImporter atPath = AssetImporter.GetAtPath(AssetDatabase.GetAssetPath(this.targets[0]));
                if (atPath && atPath.GetType() != typeof(AssetImporter))
                {
                    flag = false;
                }
            }
            if (flag)
            {
                if (GUILayout.Button("Open", EditorStyles.miniButton, new GUILayoutOption[0]))
                {
                    if (this is AssetImporterEditor)
                    {
                        AssetDatabase.OpenAsset((this as AssetImporterEditor).assetEditor.targets);
                    }
                    else
                    {
                        AssetDatabase.OpenAsset(this.targets);
                    }
                    GUIUtility.ExitGUI();
                }
            }
        }
Beispiel #2
0
        internal virtual void OnHeaderControlsGUI()
        {
            // Ensure we take up the same amount of height as regular controls
            GUILayoutUtility.GetRect(10, 10, 16, 16, EditorStyles.layerMaskField);

            GUILayout.FlexibleSpace();

            bool showOpenButton = true;
            var  importerEditor = this as AssetImporterEditor;

            // only show open button for the main object of an asset and for AssetImportInProgressProxy (asset not yet imported)
            if (importerEditor == null && !(targets[0] is AssetImportInProgressProxy))
            {
                var assetPath = AssetDatabase.GetAssetPath(targets[0]);
                // Don't show open button if the target is not an asset
                if (!AssetDatabase.IsMainAsset(targets[0]))
                {
                    showOpenButton = false;
                }
                // Don't show open button if the target has an importer
                // (but ignore AssetImporters since they're not shown)
                AssetImporter importer = AssetImporter.GetAtPath(assetPath);
                if (importer && importer.GetType() != typeof(AssetImporter))
                {
                    showOpenButton = false;
                }
            }

            if (showOpenButton && !ShouldHideOpenButton())
            {
                var assets   = importerEditor != null ? importerEditor.assetTargets : targets;
                var disabled = importerEditor != null && importerEditor.assetTarget == null;
                ShowOpenButton(assets, !disabled);
            }
        }
        public bool IsEqual(AssetImporter importer)
        {
            if(importer.GetType() != referenceImporter.GetType()) {
                throw new AssetBundleGraphException("Importer type does not match.");
            }

            if(importer.GetType() == typeof(UnityEditor.TextureImporter)) {
                return IsEqual(importer as UnityEditor.TextureImporter);
            }
            else if(importer.GetType() == typeof(UnityEditor.AudioImporter)) {
                return IsEqual(importer as UnityEditor.AudioImporter);
            }
            else if(importer.GetType() == typeof(UnityEditor.ModelImporter)) {
                return IsEqual(importer as UnityEditor.ModelImporter);
            }
            else {
                throw new AssetBundleGraphException("Unknown importer type found:" + importer.GetType());
            }
        }
Beispiel #4
0
 /// <summary>
 /// Are these settings applicable to this asset importer?
 /// </summary>
 /// <param name="assetImporter">Asset importer for current object being updated.</param>
 /// <returns>True, if these import settings should be used.</returns>
 public virtual bool IsValid(AssetImporter assetImporter)
 {
     return AssetType == assetImporter.GetType();
 }
        public void OverwriteImportSettings(AssetImporter importer)
        {
            if(importer.GetType() != referenceImporter.GetType()) {
                throw new AssetBundleGraphException("Importer type does not match.");
            }

            if(importer.GetType() == typeof(UnityEditor.TextureImporter)) {
                OverwriteImportSettings(importer as UnityEditor.TextureImporter);
            }
            else if(importer.GetType() == typeof(UnityEditor.AudioImporter)) {
                OverwriteImportSettings(importer as UnityEditor.AudioImporter);
            }
            else if(importer.GetType() == typeof(UnityEditor.ModelImporter)) {
                OverwriteImportSettings(importer as UnityEditor.ModelImporter);
            }
            else {
                throw new AssetBundleGraphException("Unknown importer type found:" + importer.GetType());
            }
        }