Stores and accesses Unity editor preferences.

 public override string GetProjectFooterTemplate(ScriptingLanguage language)
 {
     return(EditorPrefs.GetString("VSProjectFooter", base.GetProjectFooterTemplate(language)));
 }
        static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, bool explicitlySaveAsset)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;

            bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs;

            // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need
            // to verify this twice.
            if (explicitlySaveAsset && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab")))
            {
                showSaveDialog = false;
            }

            if (showSaveDialog)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }

            foreach (var assetModificationProcessorClass in AssetModificationProcessors)
            {
                const string methodName = "OnWillSaveAssets";
                MethodInfo   method     = assetModificationProcessorClass.GetMethod(methodName, BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = { assetsThatShouldBeSaved };
                    if (!CheckArguments(args, method))
                    {
                        continue;
                    }

                    string[] result;
                    using (new EditorPerformanceMarker($"{assetModificationProcessorClass.Name}.{methodName}", assetModificationProcessorClass).Auto())
                        result = (string[])method.Invoke(null, args);

                    if (result != null)
                    {
                        assetsThatShouldBeSaved = result;
                    }
                }
            }

            if (assetsThatShouldBeSaved == null)
            {
                return;
            }

            var assetsNotOpened = new List <string>();

            AssetDatabase.IsOpenForEdit(assetsThatShouldBeSaved, assetsNotOpened, StatusQueryOptions.ForceUpdate);
            assets = assetsNotOpened.ToArray();

            // Try to checkout if needed
            var notEditableAssets = new List <string>();

            if (assets.Length != 0 && !AssetDatabase.MakeEditable(assets, null, notEditableAssets))
            {
                // only save assets that can be made editable (not locked by someone else, etc.),
                // unless we are in the behavior mode that just overwrites everything anyway
                if (!EditorUserSettings.overwriteFailedCheckoutAssets)
                {
                    assetsThatShouldBeReverted = notEditableAssets.ToArray();
                    assetsThatShouldBeSaved    = assetsThatShouldBeSaved.Except(assetsThatShouldBeReverted).ToArray();
                }
            }
        }
示例#3
0
 internal static bool GetAllModulesVisible()
 {
     return(EditorPrefs.GetBool("ParticleSystemShowAllModules", true));
 }
        override public void OnInspectorGUI(InitialModuleUI initial)
        {
            EditorGUI.BeginChangeCheck();
            CollisionTypes type = (CollisionTypes)GUIPopup(s_Texts.collisionType, m_Type, s_Texts.collisionTypes);

            if (EditorGUI.EndChangeCheck())
            {
                SyncVisualization();
            }

            if (type == CollisionTypes.Plane)
            {
                DoListOfPlanesGUI();

                EditorGUI.BeginChangeCheck();
                m_PlaneVisualizationType = (PlaneVizType)GUIPopup(s_Texts.visualization, (int)m_PlaneVisualizationType, s_Texts.planeVizTypes);
                if (EditorGUI.EndChangeCheck())
                {
                    EditorPrefs.SetInt("PlaneColisionVizType", (int)m_PlaneVisualizationType);
                }

                EditorGUI.BeginChangeCheck();
                m_ScaleGrid = GUIFloat(s_Texts.scalePlane, m_ScaleGrid, "f2");
                if (EditorGUI.EndChangeCheck())
                {
                    m_ScaleGrid = Mathf.Max(0f, m_ScaleGrid);
                    EditorPrefs.SetFloat("ScalePlaneColision", m_ScaleGrid);
                }

                GUIButtonGroup(s_Texts.sceneViewEditModes, s_Texts.toolContents, GetBounds, m_ParticleSystemUI.m_ParticleEffectUI.m_Owner.customEditor);
            }
            else
            {
                GUIPopup(s_Texts.collisionMode, m_CollisionMode, s_Texts.collisionModes);
            }

            GUIMinMaxCurve(s_Texts.dampen, m_Dampen);
            GUIMinMaxCurve(s_Texts.bounce, m_Bounce);
            GUIMinMaxCurve(s_Texts.lifetimeLoss, m_LifetimeLossOnCollision);
            GUIFloat(s_Texts.minKillSpeed, m_MinKillSpeed);
            GUIFloat(s_Texts.maxKillSpeed, m_MaxKillSpeed);
            GUIFloat(s_Texts.radiusScale, m_RadiusScale);

            if (type == CollisionTypes.World)
            {
                GUIPopup(s_Texts.quality, m_Quality, s_Texts.qualitySettings);
                EditorGUI.indentLevel++;
                GUILayerMask(s_Texts.collidesWith, m_CollidesWith);
                GUIInt(s_Texts.maxCollisionShapes, m_MaxCollisionShapes);

                if (m_Quality.intValue == 0)
                {
                    GUIToggle(s_Texts.collidesWithDynamic, m_CollidesWithDynamic);
                }
                else
                {
                    GUIFloat(s_Texts.voxelSize, m_VoxelSize);
                }

                EditorGUI.indentLevel--;

                GUIFloat(s_Texts.colliderForce, m_ColliderForce);
                EditorGUI.indentLevel++;
                GUIToggle(s_Texts.multiplyColliderForceByCollisionAngle, m_MultiplyColliderForceByCollisionAngle);
                GUIToggle(s_Texts.multiplyColliderForceByParticleSpeed, m_MultiplyColliderForceByParticleSpeed);
                GUIToggle(s_Texts.multiplyColliderForceByParticleSize, m_MultiplyColliderForceByParticleSize);
                EditorGUI.indentLevel--;
            }

            GUIToggle(s_Texts.collisionMessages, m_CollisionMessages);

            EditorGUI.BeginChangeCheck();
            s_VisualizeBounds = GUIToggle(s_Texts.visualizeBounds, s_VisualizeBounds);
            if (EditorGUI.EndChangeCheck())
            {
                EditorPrefs.SetBool("VisualizeBounds", s_VisualizeBounds);
            }
        }
 public virtual void AddItemsToMenu(GenericMenu menu)
 {
     menu.AddItem(new GUIContent("Sort groups alphabetically"), this.m_SortGroupsAlphabetically, delegate
     {
         this.m_SortGroupsAlphabetically = !this.m_SortGroupsAlphabetically;
     });
     menu.AddItem(new GUIContent("Show referenced groups"), this.m_ShowReferencedBuses, delegate
     {
         this.m_ShowReferencedBuses = !this.m_ShowReferencedBuses;
     });
     menu.AddItem(new GUIContent("Show group connections"), this.m_ShowBusConnections, delegate
     {
         this.m_ShowBusConnections = !this.m_ShowBusConnections;
     });
     if (this.m_ShowBusConnections)
     {
         menu.AddItem(new GUIContent("Only highlight selected group connections"), this.m_ShowBusConnectionsOfSelection, delegate
         {
             this.m_ShowBusConnectionsOfSelection = !this.m_ShowBusConnectionsOfSelection;
         });
     }
     menu.AddSeparator("");
     menu.AddItem(new GUIContent("Vertical layout"), this.layoutMode == AudioMixerWindow.LayoutMode.Vertical, delegate
     {
         this.layoutMode = AudioMixerWindow.LayoutMode.Vertical;
     });
     menu.AddItem(new GUIContent("Horizontal layout"), this.layoutMode == AudioMixerWindow.LayoutMode.Horizontal, delegate
     {
         this.layoutMode = AudioMixerWindow.LayoutMode.Horizontal;
     });
     menu.AddSeparator("");
     menu.AddItem(new GUIContent("Use RMS metering for display"), EditorPrefs.GetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true), delegate
     {
         EditorPrefs.SetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true);
     });
     menu.AddItem(new GUIContent("Use peak metering for display"), !EditorPrefs.GetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, true), delegate
     {
         EditorPrefs.SetBool(AudioMixerWindow.kAudioMixerUseRMSMetering, false);
     });
     if (Unsupported.IsDeveloperBuild())
     {
         menu.AddSeparator("");
         menu.AddItem(new GUIContent("DEVELOPER/Groups Rendered Above"), this.m_GroupsRenderedAboveSections, delegate
         {
             this.m_GroupsRenderedAboveSections = !this.m_GroupsRenderedAboveSections;
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 10 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 10);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 20 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 20);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 40 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 40);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 80 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 80);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build 160 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(0, 7, 160);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 10 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 10);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 20 groups "), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 20);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 40 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 40);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Build chain of 80 groups"), false, delegate
         {
             this.m_Controller.BuildTestSetup(1, 1, 80);
         });
         menu.AddItem(new GUIContent("DEVELOPER/Show overlays"), this.m_ShowDeveloperOverlays, delegate
         {
             this.m_ShowDeveloperOverlays = !this.m_ShowDeveloperOverlays;
         });
     }
 }
        internal void Show(UnityEngine.Object obj, Type requiredType, SerializedProperty property, bool allowSceneObjects, List <int> allowedInstanceIDs)
        {
            this.m_AllowSceneObjects = allowSceneObjects;
            this.m_IsShowingAssets   = true;
            this.m_AllowedIDs        = allowedInstanceIDs;
            string text = "";

            if (property != null)
            {
                text = property.objectReferenceTypeString;
                obj  = property.objectReferenceValue;
                this.m_ObjectBeingEdited = property.serializedObject.targetObject;
                if (this.m_ObjectBeingEdited != null && EditorUtility.IsPersistent(this.m_ObjectBeingEdited))
                {
                    this.m_AllowSceneObjects = false;
                }
            }
            else if (requiredType != null)
            {
                text = requiredType.Name;
            }
            if (this.m_AllowSceneObjects)
            {
                if (obj != null)
                {
                    if (typeof(Component).IsAssignableFrom(obj.GetType()))
                    {
                        obj = ((Component)obj).gameObject;
                    }
                    this.m_IsShowingAssets = (EditorUtility.IsPersistent(obj) || ObjectSelector.GuessIfUserIsLookingForAnAsset(text, false));
                }
                else
                {
                    this.m_IsShowingAssets = ObjectSelector.GuessIfUserIsLookingForAnAsset(text, true);
                }
            }
            else
            {
                this.m_IsShowingAssets = true;
            }
            this.m_DelegateView      = GUIView.current;
            this.m_RequiredType      = text;
            this.m_SearchFilter      = "";
            this.m_OriginalSelection = obj;
            this.m_ModalUndoGroup    = Undo.GetCurrentGroup();
            ContainerWindow.SetFreezeDisplay(true);
            base.ShowWithMode(ShowMode.AuxWindow);
            base.titleContent = new GUIContent("Select " + text);
            Rect position = this.m_Parent.window.position;

            position.width  = EditorPrefs.GetFloat("ObjectSelectorWidth", 200f);
            position.height = EditorPrefs.GetFloat("ObjectSelectorHeight", 390f);
            base.position   = position;
            base.minSize    = new Vector2(200f, 335f);
            base.maxSize    = new Vector2(10000f, 10000f);
            this.SetupPreview();
            base.Focus();
            ContainerWindow.SetFreezeDisplay(false);
            this.m_FocusSearchFilter = true;
            this.m_Parent.AddToAuxWindowList();
            int num = (!(obj != null)) ? 0 : obj.GetInstanceID();

            if (property != null && property.hasMultipleDifferentValues)
            {
                num = 0;
            }
            if (ObjectSelector.ShouldTreeViewBeUsed(text))
            {
                this.m_ObjectTreeWithSearch.Init(base.position, this, new UnityAction <ObjectTreeForSelector.TreeSelectorData>(this.CreateAndSetTreeView), new UnityAction <TreeViewItem>(this.TreeViewSelection), new UnityAction(this.ItemWasDoubleClicked), num, 0);
            }
            else
            {
                this.InitIfNeeded();
                this.m_ListArea.InitSelection(new int[]
                {
                    num
                });
                if (num != 0)
                {
                    this.m_ListArea.Frame(num, true, false);
                }
            }
        }
        protected override void Init()
        {
            // Already initialized?
            if (m_Type != null)
            {
                return;
            }
            if (s_Texts == null)
            {
                s_Texts = new Texts();
            }

            m_Type = GetProperty("type");

            List <SerializedProperty> shownPlanes = new List <SerializedProperty>();

            for (int i = 0; i < m_Planes.Length; ++i)
            {
                m_Planes[i] = GetProperty("plane" + i); // Keep name in sync with transfer func in CollisionModule.h
                System.Diagnostics.Debug.Assert(m_Planes[i] != null);

                // Always show the first plane
                if (i == 0 || m_Planes[i].objectReferenceValue != null)
                {
                    shownPlanes.Add(m_Planes[i]);
                }
            }

            m_ShownPlanes = shownPlanes.ToArray();

            m_Dampen = new SerializedMinMaxCurve(this, s_Texts.dampen, "m_Dampen");
            m_Dampen.m_AllowCurves = false;

            m_Bounce = new SerializedMinMaxCurve(this, s_Texts.bounce, "m_Bounce");
            m_Bounce.m_AllowCurves = false;

            m_LifetimeLossOnCollision = new SerializedMinMaxCurve(this, s_Texts.lifetimeLoss, "m_EnergyLossOnCollision");
            m_LifetimeLossOnCollision.m_AllowCurves = false;

            m_MinKillSpeed = GetProperty("minKillSpeed");
            m_MaxKillSpeed = GetProperty("maxKillSpeed");
            m_RadiusScale  = GetProperty("radiusScale");

            m_PlaneVisualizationType = (PlaneVizType)EditorPrefs.GetInt("PlaneColisionVizType", (int)PlaneVizType.Solid);
            m_ScaleGrid       = EditorPrefs.GetFloat("ScalePlaneColision", 1f);
            s_VisualizeBounds = EditorPrefs.GetBool("VisualizeBounds", false);

            m_CollidesWith        = GetProperty("collidesWith");
            m_CollidesWithDynamic = GetProperty("collidesWithDynamic");
            m_MaxCollisionShapes  = GetProperty("maxCollisionShapes");

            m_Quality = GetProperty("quality");

            m_VoxelSize = GetProperty("voxelSize");

            m_CollisionMessages = GetProperty("collisionMessages");
            m_CollisionMode     = GetProperty("collisionMode");

            m_ColliderForce = GetProperty("colliderForce");
            m_MultiplyColliderForceByCollisionAngle = GetProperty("multiplyColliderForceByCollisionAngle");
            m_MultiplyColliderForceByParticleSpeed  = GetProperty("multiplyColliderForceByParticleSpeed");
            m_MultiplyColliderForceByParticleSize   = GetProperty("multiplyColliderForceByParticleSize");

            SyncVisualization();
        }
示例#8
0
 void LoadActiveSearchEngine()
 {
     activeSearchEngineId = EditorPrefs.GetString(k_ActiveSearchEnginesPrefKey + id, DefaultSearchEngineBase.engineId);
 }
        void DoToolbarGUI()
        {
            GUILayout.BeginHorizontal("Toolbar");

            using (new EditorGUI.DisabledScope(m_ParticleEffectUI == null))
            {
                if (!EditorApplication.isPlaying)
                {
                    bool isPlaying = false;

                    if (m_ParticleEffectUI != null)
                    {
                        isPlaying = m_ParticleEffectUI.IsPlaying();
                    }

                    if (GUILayout.Button(isPlaying ? ParticleEffectUI.texts.pause : ParticleEffectUI.texts.play, "ToolbarButton", GUILayout.Width(65)))
                    {
                        if (m_ParticleEffectUI != null)
                        {
                            if (isPlaying)
                            {
                                m_ParticleEffectUI.Pause();
                            }
                            else
                            {
                                m_ParticleEffectUI.Play();
                            }
                        }
                        Repaint(); // we switch texts
                    }

                    if (GUILayout.Button(ParticleEffectUI.texts.stop, "ToolbarButton"))
                    {
                        if (m_ParticleEffectUI != null)
                        {
                            m_ParticleEffectUI.Stop();
                        }
                    }
                }
                else
                {
                    // In play mode we have pulse play behavior
                    if (GUILayout.Button(ParticleEffectUI.texts.play, "ToolbarButton", GUILayout.Width(65)))
                    {
                        if (m_ParticleEffectUI != null)
                        {
                            m_ParticleEffectUI.Stop();
                            m_ParticleEffectUI.Play();
                        }
                    }
                    if (GUILayout.Button(ParticleEffectUI.texts.stop, "ToolbarButton"))
                    {
                        if (m_ParticleEffectUI != null)
                        {
                            m_ParticleEffectUI.Stop();
                        }
                    }
                }

                GUILayout.FlexibleSpace();

                // Resimulation toggle
                ParticleSystemEditorUtils.resimulation = GUILayout.Toggle(ParticleSystemEditorUtils.resimulation, ParticleEffectUI.texts.resimulation, "ToolbarButton");

                // Bounds toggle
                ParticleEffectUI.m_ShowBounds = GUILayout.Toggle(ParticleEffectUI.m_ShowBounds, ParticleEffectUI.texts.showBounds, "ToolbarButton");

                // Editor layout
                if (GUILayout.Button(ParticleEffectUI.m_VerticalLayout ? s_Icons[0] : s_Icons[1], "ToolbarButton"))
                {
                    ParticleEffectUI.m_VerticalLayout = !ParticleEffectUI.m_VerticalLayout;
                    EditorPrefs.SetBool("ShurikenVerticalLayout", ParticleEffectUI.m_VerticalLayout);
                    {
                        Clear();
                    }
                }

                // Lock toggle
                GUILayout.BeginVertical();
                GUILayout.Space(3);
                ParticleSystem lockedParticleSystem = ParticleSystemEditorUtils.lockedParticleSystem;
                bool           isLocked             = lockedParticleSystem != null;
                bool           newLocked            = GUILayout.Toggle(isLocked, s_Texts.lockParticleSystem, "IN LockButton");
                if (isLocked != newLocked)
                {
                    if (m_ParticleEffectUI != null && m_Target != null)
                    {
                        if (newLocked)
                        {
                            ParticleSystemEditorUtils.lockedParticleSystem = m_Target;
                        }
                        else
                        {
                            ParticleSystemEditorUtils.lockedParticleSystem = null;
                        }
                    }
                }
                GUILayout.EndVertical();
            }

            GUILayout.EndHorizontal();
        }
示例#10
0
        // Postprocess on all assets once an automatic import has completed
        static void OnWillSaveAssets(string[] assets, out string[] assetsThatShouldBeSaved, out string[] assetsThatShouldBeReverted, bool explicitlySaveAsset)
        {
            assetsThatShouldBeReverted = new string[0];
            assetsThatShouldBeSaved    = assets;

            bool showSaveDialog = assets.Length > 0 && EditorPrefs.GetBool("VerifySavingAssets", false) && InternalEditorUtility.isHumanControllingUs;

            // If we are only saving a single scene or prefab and the user explicitly said we should, skip the dialog. We don't need
            // to verify this twice.
            if (explicitlySaveAsset && assets.Length == 1 && (assets[0].EndsWith(".unity") || assets[0].EndsWith(".prefab")))
            {
                showSaveDialog = false;
            }

            if (showSaveDialog)
            {
                AssetSaveDialog.ShowWindow(assets, out assetsThatShouldBeSaved);
            }
            else
            {
                assetsThatShouldBeSaved = assets;
            }

            foreach (var assetModificationProcessorClass in AssetModificationProcessors)
            {
                MethodInfo method = assetModificationProcessorClass.GetMethod("OnWillSaveAssets", BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Static);
                if (method != null)
                {
                    object[] args = { assetsThatShouldBeSaved };
                    if (!CheckArguments(args, method))
                    {
                        continue;
                    }

                    string[] result = (string[])method.Invoke(null, args);

                    if (result != null)
                    {
                        assetsThatShouldBeSaved = result;
                    }
                }
            }

            if (assetsThatShouldBeSaved == null)
            {
                return;
            }

            var assetsNotOpened = new List <string>();

            foreach (string asset in assetsThatShouldBeSaved)
            {
                if (!AssetDatabase.IsOpenForEdit(asset, StatusQueryOptions.ForceUpdate))
                {
                    assetsNotOpened.Add(asset);
                }
            }
            assets = assetsNotOpened.ToArray();

            // Try to checkout if needed. This may fail but is caught below.
            var editableAssets = new string[assets.Length];

            if (assets.Length != 0 && !Provider.MakeEditable(assets, editableAssets))
            {
                // TODO: fix this behaviour to make save asset honour version control result
                // keep previous behaviour which is save all assets even if checkout fails
                // TODO: this needs to consider and handle saving assets which have not been
                // added to version control. They have to be added to version control before
                // calling MakeEditable.
                //assetsThatShouldBeSaved = editableAssets;
                return;
            }
        }
 private static void PreferencesGUI()
 {
     using (new SettingsWindow.GUIScope())
     {
         EditorGUI.BeginChangeCheck();
         var val = EditorGUILayout.Toggle(GridBrushProperties.floodFillPreviewLabel, EditorPrefs.GetBool(GridBrushProperties.floodFillPreviewEditorPref, true));
         if (EditorGUI.EndChangeCheck())
         {
             EditorPrefs.SetBool(GridBrushProperties.floodFillPreviewEditorPref, val);
         }
     }
 }
示例#12
0
 public static void ReadPreferences()
 {
     s_AssetPipelineVersionForNewProjects = (AssetPipelineVersion)EditorPrefs.GetInt(kAssetPipelineVersionForNewProjects, (int)AssetPipelineVersion.Version2);
     s_CacheServer2IPAddress = EditorPrefs.GetString(kIPAddress2Key, s_CacheServer2IPAddress);
     s_CacheServer2Mode      = (CacheServer2Mode)EditorPrefs.GetInt(kMode2Key, (int)CacheServer2Mode.Disabled);
     s_CacheServerIPAddress  = EditorPrefs.GetString(kIPAddressKey, s_CacheServerIPAddress);
     s_CacheServerMode       = (CacheServerMode)EditorPrefs.GetInt(kModeKey, (int)(EditorPrefs.GetBool(kDeprecatedEnabledKey) ? CacheServerMode.Remote : CacheServerMode.Disabled));
     s_LocalCacheServerSize  = EditorPrefs.GetInt(LocalCacheServer.SizeKey, 10);
     s_CachePath             = EditorPrefs.GetString(LocalCacheServer.PathKey);
     s_EnableCustomPath      = EditorPrefs.GetBool(LocalCacheServer.CustomPathKey);
 }
示例#13
0
        internal void Show(UnityObject obj, Type requiredType, SerializedProperty property, bool allowSceneObjects, List <int> allowedInstanceIDs, Action <UnityObject> onObjectSelectorClosed, Action <UnityObject> onObjectSelectedUpdated)
        {
            m_ObjectSelectorReceiver = null;
            m_AllowSceneObjects      = allowSceneObjects;
            m_IsShowingAssets        = true;
            m_AllowedIDs             = allowedInstanceIDs;

            m_OnObjectSelectorClosed  = onObjectSelectorClosed;
            m_OnObjectSelectorUpdated = onObjectSelectedUpdated;

            if (property != null)
            {
                if (requiredType == null)
                {
                    ScriptAttributeUtility.GetFieldInfoFromProperty(property, out requiredType);
                    // case 951876: built-in types do not actually have reflectable fields, so their object types must be extracted from the type string
                    // this works because built-in types will only ever have serialized references to other built-in types, which this window's filter expects as unqualified names
                    if (requiredType == null)
                    {
                        m_RequiredType = s_MatchPPtrTypeName.Match(property.type).Groups[1].Value;
                    }
                }

                obj = property.objectReferenceValue;
                m_ObjectBeingEdited = property.serializedObject.targetObject;

                // Do not allow to show scene objects if the object being edited is persistent
                if (m_ObjectBeingEdited != null && EditorUtility.IsPersistent(m_ObjectBeingEdited))
                {
                    m_AllowSceneObjects = false;
                }
            }

            // Set which tab should be visible at startup
            if (m_AllowSceneObjects)
            {
                if (obj != null)
                {
                    if (typeof(Component).IsAssignableFrom(obj.GetType()))
                    {
                        obj = ((Component)obj).gameObject;
                    }
                    // Set the right tab visible (so we can see our selection)
                    m_IsShowingAssets = EditorUtility.IsPersistent(obj);
                }
                else
                {
                    m_IsShowingAssets = (requiredType != typeof(GameObject) && !typeof(Component).IsAssignableFrom(requiredType));
                }
            }
            else
            {
                m_IsShowingAssets = true;
            }

            // Set member variables
            m_DelegateView = GUIView.current;
            // type filter requires unqualified names for built-in types, but will prioritize them over user types, so ensure user types are namespace-qualified
            if (requiredType != null)
            {
                m_RequiredType = typeof(ScriptableObject).IsAssignableFrom(requiredType) || typeof(MonoBehaviour).IsAssignableFrom(requiredType) ? requiredType.FullName : requiredType.Name;
            }
            m_SearchFilter      = "";
            m_OriginalSelection = obj;
            m_ModalUndoGroup    = Undo.GetCurrentGroup();

            // Freeze to prevent flicker on OSX.
            // Screen will be updated again when calling
            // SetFreezeDisplay(false) further down.
            ContainerWindow.SetFreezeDisplay(true);

            ShowWithMode(ShowMode.AuxWindow);
            titleContent = EditorGUIUtility.TrTextContent("Select " + (requiredType == null ? m_RequiredType : requiredType.Name));

            // Deal with window size
            Rect p = m_Parent.window.position;

            p.width  = EditorPrefs.GetFloat("ObjectSelectorWidth", 200);
            p.height = EditorPrefs.GetFloat("ObjectSelectorHeight", 390);
            position = p;
            minSize  = new Vector2(kMinWidth, kMinTopSize + kPreviewExpandedAreaHeight + 2 * kPreviewMargin);
            maxSize  = new Vector2(10000, 10000);
            SetupPreview();

            // Focus
            Focus();
            ContainerWindow.SetFreezeDisplay(false);

            m_FocusSearchFilter = true;

            // Add after unfreezing display because AuxWindowManager.cpp assumes that aux windows are added after we get 'got/lost'- focus calls.
            m_Parent.AddToAuxWindowList();

            // Initial selection
            int initialSelection = obj != null?obj.GetInstanceID() : 0;

            if (property != null && property.hasMultipleDifferentValues)
            {
                initialSelection = 0; // don't select anything on multi selection
            }
            if (ShouldTreeViewBeUsed(requiredType))
            {
                m_ObjectTreeWithSearch.Init(position, this, CreateAndSetTreeView, TreeViewSelection, ItemWasDoubleClicked, initialSelection, 0);
            }
            else
            {
                // To frame the selected item we need to wait to initialize the search until our window has been setup
                InitIfNeeded();
                m_ListArea.InitSelection(new[] { initialSelection });
                if (initialSelection != 0)
                {
                    m_ListArea.Frame(initialSelection, true, false);
                }
            }
        }
示例#14
0
 public void ToggleExpanded()
 {
     this.m_CachedPref = -this.m_CachedPref;
     EditorPrefs.SetFloat(this.m_PrefName, this.m_CachedPref);
 }
示例#15
0
 public void SetExpanded(bool expanded)
 {
     this.m_CachedPref = Mathf.Abs(this.m_CachedPref) * (float)((!expanded) ? -1 : 1);
     EditorPrefs.SetFloat(this.m_PrefName, this.m_CachedPref);
 }
示例#16
0
 public void OnDisable()
 {
     AudioUtil.StopAllClips();
     EditorPrefs.SetBool("AutoPlayAudio", AudioClipInspector.m_bAutoPlay);
 }