private static float GetDesiredImportWorkerCountPctOfLogicalCPUs() { return(EditorPrefs.GetFloat(kDesiredImportWorkerCountPctOfLogicalCPUsKey, kDefaultDesiredImportWorkerCountPctOfLogicalCPUs)); }
internal void Show(UnityObject obj, Type requiredType, UnityObject objectBeingEdited, bool allowSceneObjects, List <int> allowedInstanceIDs = null, Action <UnityObject> onObjectSelectorClosed = null, Action <UnityObject> onObjectSelectedUpdated = null) { m_ObjectSelectorReceiver = null; m_AllowSceneObjects = allowSceneObjects; m_IsShowingAssets = true; m_SkipHiddenPackages = true; m_AllowedIDs = allowedInstanceIDs; m_ObjectBeingEdited = objectBeingEdited; m_LastSelectedInstanceId = obj?.GetInstanceID() ?? 0; m_OnObjectSelectorClosed = onObjectSelectorClosed; m_OnObjectSelectorUpdated = onObjectSelectedUpdated; // 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(); // Show custom selector if available if (SearchService.ObjectSelector.HasEngineOverride()) { m_SearchSessionHandler.BeginSession(() => { SelectorHandlerType selectorConstraint = null; if (m_EditedProperty != null) { selectorConstraint = GetSelectorHandlerFromProperty(m_EditedProperty); } return(new SearchService.ObjectSelectorSearchContext { currentObject = obj, editedObjects = m_EditedProperty != null ? m_EditedProperty.serializedObject.targetObjects : new[] { objectBeingEdited }, requiredTypes = new[] { requiredType }, requiredTypeNames = new[] { m_RequiredType }, allowedInstanceIds = allowedInstanceIDs, visibleObjects = allowSceneObjects ? SearchService.VisibleObjects.All : SearchService.VisibleObjects.Assets, selectorConstraint = selectorConstraint }); }); var searchContext = (SearchService.ObjectSelectorSearchContext)m_SearchSessionHandler.context; Action <UnityObject> onSelectionChanged = selectedObj => { m_LastSelectedInstanceId = selectedObj == null ? 0 : selectedObj.GetInstanceID(); NotifySelectionChanged(false); }; Action <UnityObject, bool> onSelectorClosed = (selectedObj, canceled) => { m_SearchSessionHandler.EndSession(); if (canceled) { // Undo changes we have done in the ObjectSelector Undo.RevertAllDownToGroup(m_ModalUndoGroup); m_LastSelectedInstanceId = 0; } else { m_LastSelectedInstanceId = selectedObj == null ? 0 : selectedObj.GetInstanceID(); } m_EditedProperty = null; NotifySelectorClosed(false); }; if (SearchService.ObjectSelector.SelectObject(searchContext, onSelectorClosed, onSelectionChanged)) { return; } } // 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 == null ? new Rect(0, 0, 1, 1) : 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. if (m_Parent != null) { m_Parent.AddToAuxWindowList(); } // Initial selection int initialSelection = obj != null?obj.GetInstanceID() : 0; if (initialSelection != 0) { var assetPath = AssetDatabase.GetAssetPath(initialSelection); if (m_SkipHiddenPackages && !PackageManagerUtilityInternal.IsPathInVisiblePackage(assetPath)) { m_SkipHiddenPackages = false; } } if (ShouldTreeViewBeUsed(m_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); } } }
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 = string.Empty; if (property != null) { text = property.objectReferenceTypeString; obj = property.objectReferenceValue; UnityEngine.Object targetObject = property.serializedObject.targetObject; if (targetObject != null && EditorUtility.IsPersistent(targetObject)) { 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 = string.Empty; 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(); }
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); } } }
internal void Show(UnityEngine.Object obj, Type requiredType, SerializedProperty property, bool allowSceneObjects, List <int> allowedInstanceIDs, Action <UnityEngine.Object> onObjectSelectorClosed, Action <UnityEngine.Object> onObjectSelectedUpdated) { this.m_ObjectSelectorReceiver = null; this.m_AllowSceneObjects = allowSceneObjects; this.m_IsShowingAssets = true; this.m_AllowedIDs = allowedInstanceIDs; this.m_OnObjectSelectorClosed = onObjectSelectorClosed; this.m_OnObjectSelectorUpdated = onObjectSelectedUpdated; if (property != null) { if (requiredType == null) { ScriptAttributeUtility.GetFieldInfoFromProperty(property, out requiredType); if (requiredType == null) { this.m_RequiredType = this.s_MatchPPtrTypeName.Match(property.type).Groups[1].Value; } } obj = property.objectReferenceValue; this.m_ObjectBeingEdited = property.serializedObject.targetObject; if (this.m_ObjectBeingEdited != null && EditorUtility.IsPersistent(this.m_ObjectBeingEdited)) { this.m_AllowSceneObjects = false; } } if (this.m_AllowSceneObjects) { if (obj != null) { if (typeof(Component).IsAssignableFrom(obj.GetType())) { obj = ((Component)obj).gameObject; } this.m_IsShowingAssets = EditorUtility.IsPersistent(obj); } else { this.m_IsShowingAssets = (requiredType != typeof(GameObject) && !typeof(Component).IsAssignableFrom(requiredType)); } } else { this.m_IsShowingAssets = true; } this.m_DelegateView = GUIView.current; if (requiredType != null) { this.m_RequiredType = ((!typeof(ScriptableObject).IsAssignableFrom(requiredType) && !typeof(MonoBehaviour).IsAssignableFrom(requiredType)) ? requiredType.Name : requiredType.FullName); } this.m_SearchFilter = ""; this.m_OriginalSelection = obj; this.m_ModalUndoGroup = Undo.GetCurrentGroup(); ContainerWindow.SetFreezeDisplay(true); base.ShowWithMode(ShowMode.AuxWindow); base.titleContent = EditorGUIUtility.TrTextContent("Select " + ((requiredType != null) ? requiredType.Name : this.m_RequiredType), null, null); 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(requiredType)) { 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); } } }
public bool InitializeIfNeeded(IEnumerable <ParticleSystem> systems) { bool flag = false; ParticleSystem[] array = systems.ToArray <ParticleSystem>(); bool flag2 = array.Count <ParticleSystem>() > 1; bool flag3 = false; ParticleSystem particleSystem = null; ParticleSystem[] array2 = array; int i = 0; while (i < array2.Length) { ParticleSystem particleSystem2 = array2[i]; if (flag2) { ParticleSystem[] array3 = new ParticleSystem[] { particleSystem2 }; particleSystem = particleSystem2; goto IL_11F; } ParticleSystem root = ParticleSystemEditorUtils.GetRoot(particleSystem2); if (!(root == null)) { ParticleSystem[] array3 = ParticleEffectUI.GetParticleSystems(root); particleSystem = root; if (this.m_SelectedParticleSystems != null && this.m_SelectedParticleSystems.Count > 0) { if (root == ParticleSystemEditorUtils.GetRoot(this.m_SelectedParticleSystems[0])) { if (this.m_ParticleSystemCurveEditor != null && this.m_Emitters != null && array3.Length == this.m_Emitters.Length && particleSystem2.gameObject.activeInHierarchy == this.m_EmittersActiveInHierarchy) { this.m_SelectedParticleSystems = new List <ParticleSystem>(); this.m_SelectedParticleSystems.Add(particleSystem2); if (this.IsShowOnlySelectedMode()) { this.RefreshShowOnlySelected(); } goto IL_1E6; } } } goto IL_11F; } IL_1E6: i++; continue; IL_11F: if (this.m_ParticleSystemCurveEditor != null) { this.Clear(); } flag3 = true; if (!flag) { this.m_SelectedParticleSystems = new List <ParticleSystem>(); flag = true; } this.m_SelectedParticleSystems.Add(particleSystem2); if (!flag2) { this.m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); this.m_ParticleSystemCurveEditor.Init(); ParticleSystem[] array3; int num = array3.Length; if (num > 0) { this.m_Emitters = new ParticleSystemUI[num]; for (int j = 0; j < num; j++) { this.m_Emitters[j] = new ParticleSystemUI(); this.m_Emitters[j].Init(this, new ParticleSystem[] { array3[j] }); } this.m_EmittersActiveInHierarchy = particleSystem2.gameObject.activeInHierarchy; } } goto IL_1E6; } if (flag3) { if (flag2) { this.m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); this.m_ParticleSystemCurveEditor.Init(); int count = this.m_SelectedParticleSystems.Count; if (count > 0) { this.m_Emitters = new ParticleSystemUI[1]; this.m_Emitters[0] = new ParticleSystemUI(); this.m_Emitters[0].Init(this, this.m_SelectedParticleSystems.ToArray()); this.m_EmittersActiveInHierarchy = this.m_SelectedParticleSystems[0].gameObject.activeInHierarchy; } } ParticleSystemUI[] emitters = this.m_Emitters; for (int k = 0; k < emitters.Length; k++) { ParticleSystemUI particleSystemUI = emitters[k]; ModuleUI[] modules = particleSystemUI.m_Modules; for (int l = 0; l < modules.Length; l++) { ModuleUI moduleUI = modules[l]; if (moduleUI != null) { moduleUI.Validate(); } } } if (ParticleEffectUI.GetAllModulesVisible()) { this.SetAllModulesVisible(true); } this.m_EmitterAreaWidth = EditorPrefs.GetFloat("ParticleSystemEmitterAreaWidth", ParticleEffectUI.k_MinEmitterAreaSize.x); this.m_CurveEditorAreaHeight = EditorPrefs.GetFloat("ParticleSystemCurveEditorAreaHeight", ParticleEffectUI.k_MinCurveAreaSize.y); this.SetShowOnlySelectedMode(this.m_Owner is ParticleSystemWindow && SessionState.GetBool("ShowSelected" + particleSystem.GetInstanceID(), false)); this.m_EmitterAreaScrollPos.x = SessionState.GetFloat("CurrentEmitterAreaScroll", 0f); if (this.ShouldManagePlaybackState(particleSystem)) { Vector3 vector = SessionState.GetVector3("SimulationState" + particleSystem.GetInstanceID(), Vector3.zero); if (particleSystem.GetInstanceID() == (int)vector.x) { float z = vector.z; if (z > 0f) { ParticleSystemEditorUtils.playbackTime = z; ParticleSystemEditorUtils.PerformCompleteResimulation(); } } if (ParticleEffectUI.m_MainPlaybackSystem != particleSystem) { this.Play(); } } } ParticleEffectUI.m_MainPlaybackSystem = particleSystem; return(flag3); }
public float GetFloat(string key) { return(EditorPrefs.GetFloat(key)); }
public static float GetFloat(string key) { float defaultValue = 0.0f; return(EditorPrefs.GetFloat(key, defaultValue)); }
// Should be called often to ensure we catch if selected Particle System is dragged in/out of root hierarchy public bool InitializeIfNeeded(IEnumerable <ParticleSystem> systems) { bool anyAdded = false; ParticleSystem[] allSystems = systems.ToArray(); bool usingMultiEdit = (allSystems.Count() > 1); bool initializeRequired = false; ParticleSystem mainSystem = null; foreach (ParticleSystem shuriken in allSystems) { ParticleSystem[] shurikens; if (!usingMultiEdit) { ParticleSystem root = ParticleSystemEditorUtils.GetRoot(shuriken); if (root == null) { continue; } shurikens = GetParticleSystems(root); mainSystem = root; // Check if we need to re-initialize? if (m_SelectedParticleSystems != null && m_SelectedParticleSystems.Count > 0) { if (root == ParticleSystemEditorUtils.GetRoot(m_SelectedParticleSystems[0])) { if (m_ParticleSystemCurveEditor != null && m_Emitters != null && shurikens.Length == m_Emitters.Length && shuriken.gameObject.activeInHierarchy == m_EmittersActiveInHierarchy) { m_SelectedParticleSystems = new List <ParticleSystem>(); m_SelectedParticleSystems.Add(shuriken); if (IsShowOnlySelectedMode()) { RefreshShowOnlySelected(); // always refresh } continue; } } } } else { // in multi-edit mode, we explicitly choose the systems to edit, so don't automatically add child systems or search for the root shurikens = new ParticleSystem[] { shuriken }; mainSystem = shuriken; } // Cleanup before initializing if (m_ParticleSystemCurveEditor != null) { Clear(); } // Now initialize initializeRequired = true; if (!anyAdded) { m_SelectedParticleSystems = new List <ParticleSystem>(); anyAdded = true; } m_SelectedParticleSystems.Add(shuriken); // Single edit emitter setup if (!usingMultiEdit) { // Init CurveEditor before modules (they may add curves during construction) m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); m_ParticleSystemCurveEditor.Init(); int numEmitters = shurikens.Length; if (numEmitters > 0) { m_Emitters = new ParticleSystemUI[numEmitters]; for (int i = 0; i < numEmitters; ++i) { m_Emitters[i] = new ParticleSystemUI(); m_Emitters[i].Init(this, new ParticleSystem[] { shurikens[i] }); } m_EmittersActiveInHierarchy = shuriken.gameObject.activeInHierarchy; } } } if (initializeRequired) { // Multi-edit emitter setup if (usingMultiEdit) { // Init CurveEditor before modules (they may add curves during construction) m_ParticleSystemCurveEditor = new ParticleSystemCurveEditor(); m_ParticleSystemCurveEditor.Init(); int numEmitters = m_SelectedParticleSystems.Count; if (numEmitters > 0) { m_Emitters = new ParticleSystemUI[1]; m_Emitters[0] = new ParticleSystemUI(); m_Emitters[0].Init(this, m_SelectedParticleSystems.ToArray()); m_EmittersActiveInHierarchy = m_SelectedParticleSystems[0].gameObject.activeInHierarchy; } } // Allow modules to validate their state (the user can have moved emitters around in the hierarchy) foreach (ParticleSystemUI e in m_Emitters) { foreach (ModuleUI m in e.m_Modules) { if (m != null) { m.Validate(); } } } // Sync to state if (GetAllModulesVisible()) { SetAllModulesVisible(true); } m_EmitterAreaWidth = EditorPrefs.GetFloat("ParticleSystemEmitterAreaWidth", k_MinEmitterAreaSize.x); m_CurveEditorAreaHeight = EditorPrefs.GetFloat("ParticleSystemCurveEditorAreaHeight", k_MinCurveAreaSize.y); // For now only allow ShowOnlySelectedMode for ParticleSystemWindow SetShowOnlySelectedMode((m_Owner is ParticleSystemWindow) ? SessionState.GetBool(k_ShowSelectedId + mainSystem.GetInstanceID(), false) : false); m_EmitterAreaScrollPos.x = SessionState.GetFloat("CurrentEmitterAreaScroll", 0.0f); if (ShouldManagePlaybackState(mainSystem)) { // Restore lastPlayBackTime if available in session cache Vector3 simulationState = SessionState.GetVector3(k_SimulationStateId + mainSystem.GetInstanceID(), Vector3.zero); if (mainSystem.GetInstanceID() == (int)simulationState.x) { float lastPlayBackTime = simulationState.z; if (lastPlayBackTime > 0f) { ParticleSystemEditorUtils.playbackTime = lastPlayBackTime; ParticleSystemEditorUtils.PerformCompleteResimulation(); } } // Play when selecting a new particle effect if (m_MainPlaybackSystem != mainSystem) { Play(); } } } m_MainPlaybackSystem = mainSystem; return(initializeRequired); }
public float GetFloat(string key) => EditorPrefs.GetFloat(key);
public SavedFloat(string name, float value) { this.m_Name = name; this.m_Value = EditorPrefs.GetFloat(name, value); }