public void AddressableAssetSettings_OnPostprocessAllAssets_MovedGroupNotTriggerSettingsSave() { // Setup var importedAssets = new string[0]; var deletedAssets = new string[0]; var movedAssets = new string[1]; var movedFromAssetPaths = new string[1]; var newGroup = ScriptableObject.CreateInstance <AddressableAssetGroup>(); newGroup.Name = "testGroup"; var groupPath = ConfigFolder + "/AssetGroups/" + newGroup.Name + ".asset"; AssetDatabase.CreateAsset(newGroup, groupPath); newGroup.Initialize(ScriptableObject.CreateInstance <AddressableAssetSettings>(), "testGroup", AssetDatabase.AssetPathToGUID(groupPath), false); EditorUtility.ClearDirty(Settings); var prevDC = EditorUtility.GetDirtyCount(Settings); Settings.groups.Add(newGroup); string newGroupPath = ConfigFolder + "/AssetGroups/changeGroup.asset"; AssetDatabase.MoveAsset(groupPath, newGroupPath); movedAssets[0] = newGroupPath; movedFromAssetPaths[0] = groupPath; // Test Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Assert.AreEqual(prevDC, EditorUtility.GetDirtyCount(Settings)); Assert.IsFalse(EditorUtility.IsDirty(Settings)); //Cleanup Settings.RemoveGroup(newGroup); }
public void AddressableAssetSettings_OnPostprocessAllAssets_AddDeleteGroupTriggersSettingsSave() { // Setup var importedAssets = new string[1]; var deletedAssets = new string[0]; var movedAssets = new string[0]; var movedFromAssetPaths = new string[0]; var newGroup = ScriptableObject.CreateInstance <AddressableAssetGroup>(); newGroup.Name = "testGroup"; var groupPath = ConfigFolder + "/AssetGroups/" + newGroup.Name + ".asset"; AssetDatabase.CreateAsset(newGroup, groupPath); newGroup.Initialize(ScriptableObject.CreateInstance <AddressableAssetSettings>(), "testGroup", AssetDatabase.AssetPathToGUID(groupPath), false); importedAssets[0] = groupPath; EditorUtility.ClearDirty(Settings); var prevDC = EditorUtility.GetDirtyCount(Settings); // Test Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Assert.AreEqual(prevDC + 1, EditorUtility.GetDirtyCount(Settings)); Assert.IsTrue(EditorUtility.IsDirty(Settings)); deletedAssets = new string[1]; importedAssets = new string[0]; deletedAssets[0] = groupPath; EditorUtility.ClearDirty(Settings); prevDC = EditorUtility.GetDirtyCount(Settings); Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Assert.AreEqual(prevDC + 2, EditorUtility.GetDirtyCount(Settings)); Assert.IsTrue(EditorUtility.IsDirty(Settings)); }
public void AddressableAssetSettings_OnPostprocessAllAssets_MovedAssetToResourcesNotTriggerSettingsSave() { // Setup var importedAssets = new string[0]; var deletedAssets = new string[0]; var movedAssets = new string[1]; var movedFromAssetPaths = new string[1]; var assetPath = ConfigFolder + "/test.prefab"; var newAssetPath = ConfigFolder + "/resources/test.prefab"; if (!Directory.Exists(ConfigFolder + "/resources")) { Directory.CreateDirectory(ConfigFolder + "/resources"); AssetDatabase.Refresh(); } Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(newAssetPath), Settings.groups[0]); movedAssets[0] = newAssetPath; movedFromAssetPaths[0] = assetPath; EditorUtility.ClearDirty(Settings); var prevDC = EditorUtility.GetDirtyCount(Settings); Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Assert.AreEqual(prevDC, EditorUtility.GetDirtyCount(Settings)); Assert.IsFalse(EditorUtility.IsDirty(Settings)); // Cleanup AssetDatabase.MoveAsset(newAssetPath, assetPath); Settings.CreateOrMoveEntry(AssetDatabase.AssetPathToGUID(assetPath), Settings.groups[0]); Directory.Delete(ConfigFolder + "/resources"); }
public override BuildStepResult RunBuildStep(BuildContext context) { context.SetValue(new PlayerSettingsState() { Contents = EditorJsonUtility.ToJson(PlayerSettingsState.Target), IsDirty = EditorUtility.GetDirtyCount(PlayerSettingsState.Target) > 0 }); var serializedObject = new SerializedObject(PlayerSettingsState.Target); var profile = GetRequiredComponent <ClassicBuildProfile>(context); var generalSettings = GetRequiredComponent <GeneralSettings>(context); var scriptingSettings = GetRequiredComponent <ClassicScriptingSettings>(context); var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(profile.Target); // Get serialized properties for things which don't have API exposed SerializedProperty gcIncremental; var result = FindProperty(serializedObject, nameof(gcIncremental), out gcIncremental); if (result.Failed) { return(result); } PlayerSettings.productName = generalSettings.ProductName; PlayerSettings.companyName = generalSettings.CompanyName; // Scripting Settings PlayerSettings.SetScriptingBackend(targetGroup, scriptingSettings.ScriptingBackend); PlayerSettings.SetIl2CppCompilerConfiguration(targetGroup, scriptingSettings.Il2CppCompilerConfiguration); gcIncremental.boolValue = scriptingSettings.UseIncrementalGC; EditorUtility.ClearDirty(PlayerSettingsState.Target); return(Success()); }
public override BuildStepResult RunStep(BuildContext context) { context.Set(new PlayerSettingsState() { Contents = EditorJsonUtility.ToJson(PlayerSettingsState.Target), IsDirty = EditorUtility.GetDirtyCount(PlayerSettingsState.Target) > 0 }); var serializedObject = new SerializedObject(PlayerSettingsState.Target); var settings = context.BuildSettings; var profile = settings.GetComponent <ClassicBuildProfile>(); var generalSettings = settings.GetComponent <GeneralSettings>(); var scriptingSettings = settings.GetComponent <ClassicScriptingSettings>(); var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(profile.Target); // Get serialized properties for things which don't have API exposed SerializedProperty gcIncremental; var result = FindProperty(serializedObject, nameof(gcIncremental), out gcIncremental); if (result.Failed) { return(result); } PlayerSettings.productName = generalSettings.ProductName; PlayerSettings.companyName = generalSettings.CompanyName; // Scripting Settings PlayerSettings.SetScriptingBackend(targetGroup, scriptingSettings.ScriptingBackend); PlayerSettings.SetIl2CppCompilerConfiguration(targetGroup, scriptingSettings.Il2CppCompilerConfiguration); gcIncremental.boolValue = scriptingSettings.UseIncrementalGC; switch (profile.Target) { case BuildTarget.Android: { var androidSettings = settings.GetComponent <AndroidSettings>(); AndroidBuildType androidBuildType; switch (profile.Configuration) { case BuildConfiguration.Debug: androidBuildType = AndroidBuildType.Debug; break; case BuildConfiguration.Develop: androidBuildType = AndroidBuildType.Development; break; case BuildConfiguration.Release: androidBuildType = AndroidBuildType.Release; break; default: throw new NotImplementedException("AndroidBuildType"); } EditorUserBuildSettings.androidBuildType = androidBuildType; PlayerSettings.Android.targetArchitectures = androidSettings.TargetArchitectures; PlayerSettings.SetApplicationIdentifier(BuildTargetGroup.Android, androidSettings.PackageName); } break; } EditorUtility.ClearDirty(PlayerSettingsState.Target); return(Success()); }
public static void ClearDirty() { //ActiveEditorTracker.sharedTracker.ClearDirty(); foreach (var comp in GetAllSceneComponents()) { EditorUtility.ClearDirty(comp); } EditorSceneManager.ClearSceneDirtiness(EditorSceneManager.GetActiveScene()); }
private static void ClearPlayerSettingsDirtyFlag() { var settings = Resources.FindObjectsOfTypeAll <PlayerSettings>(); if (settings != null && settings.Length > 0) { EditorUtility.ClearDirty(settings[0]); } }
public virtual void Setup() { var sharedTableData = ScriptableObject.CreateInstance <SharedTableData>(); Table = ScriptableObject.CreateInstance <StringTable>(); Table.SharedData = sharedTableData; // Start with assets that are not dirty EditorUtility.ClearDirty(Table); EditorUtility.ClearDirty(sharedTableData); }
public static void SetDirty(this Object self, bool dirty) { if (dirty) { EditorUtility.SetDirty(self); } else { EditorUtility.ClearDirty(self); } }
public void Save() { string path; if (asset == null) { asset = (NoiseAsset)ScriptableObject.CreateInstance(typeof(NoiseAsset)); path = EditorUtility.SaveFilePanelInProject("Save Asset", "New NoisePerspective Asset", "asset", "Select Location"); try { AssetDatabase.CreateAsset(asset, path); } catch { Debug.LogWarning("Asset Not Saved"); return; } } if (NodeManager.Instance.nodes != null && NodeManager.Instance.nodes.Count > 0) { Node[] nodeArray = NodeManager.Instance.nodes.ToArray(); Connection[] connectionArray; if (ConnectionManager.Instance.connections != null) { connectionArray = ConnectionManager.Instance.connections.ToArray(); } else { connectionArray = new Connection[0]; } asset.saveData = Data.DataProcessor.WriteToString(nodeArray, connectionArray); if (ConnectionManager.Instance.connections != null) { asset.connections = Data.DataProcessor.WriteConnections(ConnectionManager.Instance.connections.ToArray()); } } asset.useBezier = ConnectionManager.Instance.useBezierConnections; asset.globalHeightStrength = NodeManager.Instance.globalHeightStrength; EditorUtility.SetDirty(asset); AssetDatabase.SaveAssets(); EditorUtility.ClearDirty(asset); }
public override BuildResult Run(BuildContext context) { var backups = new UnitySettingsState[] { new UnitySettingsState(UnitySettingsState.PlayerSettingsAsset), new UnitySettingsState(UnitySettingsState.EditorUserBuildSettingsAsset) }; context.SetValue(backups); var serializedObject = new SerializedObject(UnitySettingsState.PlayerSettingsAsset); var generalSettings = context.GetComponentOrDefault <GeneralSettings>(); var scriptingSettings = context.GetComponentOrDefault <ClassicScriptingSettings>(); var strippingOptions = context.GetComponentOrDefault <ClassicCodeStrippingOptions>(); var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(context.GetValue <ClassicSharedData>().BuildTarget); // Get serialized properties for things which don't have API exposed SerializedProperty gcIncremental; var result = FindProperty(context, serializedObject, nameof(gcIncremental), out gcIncremental); if (result.Failed) { return(result); } PlayerSettings.productName = generalSettings.ProductName; PlayerSettings.companyName = generalSettings.CompanyName; // Scripting Settings PlayerSettings.SetScriptingBackend(targetGroup, scriptingSettings.ScriptingBackend); PlayerSettings.SetIl2CppCompilerConfiguration(targetGroup, scriptingSettings.Il2CppCompilerConfiguration); gcIncremental.boolValue = scriptingSettings.UseIncrementalGC; PlayerSettings.stripEngineCode = strippingOptions.StripEngineCode; PlayerSettings.SetManagedStrippingLevel(targetGroup, strippingOptions.ManagedStrippingLevel); if (context.TryGetComponent <ScriptingDebuggerSettings>(out var debuggerSettings)) { // Don't set EditorUserBuildSettings.allowDebugging, since it gets overriden by BuildOptions we provide in BuildPlayerStep EditorUserBuildSettings.waitForManagedDebugger = debuggerSettings.WaitForManagedDebugger; } foreach (var b in backups) { EditorUtility.ClearDirty(b.Target); } return(context.Success()); }
public void AssetReferenceDrawer_SetObject_SetToNullDirtiesObject() { // Setup Original AssetReference to not be null and property var property = SetupForSetObjectTests(); // Test string guid; EditorUtility.ClearDirty(property.serializedObject.targetObject); var prevDirty = EditorUtility.IsDirty(property.serializedObject.targetObject); m_AssetReferenceDrawer.SetObject(property, null, out guid); Assert.IsFalse(prevDirty); Assert.IsTrue(EditorUtility.IsDirty(property.serializedObject.targetObject)); }
void ChangeUrl(string newUrl, bool forceDirty = true) { OpenUrl.Url = MakeProperUrl(newUrl); var validatedUrl = SimpleUI.GetValidatedUrl(newUrl); OpenUrl.Url_ID = prefabs.First(p => p.Url.Equals(validatedUrl)).ID; // Save the changes back to the object if (forceDirty) { EditorUtility.SetDirty(OpenUrl); } else { EditorUtility.ClearDirty(OpenUrl); } }
public void AddressableAssetSettings_OnPostprocessAllAssets_ChangeImportedAssetsDoesNotTriggerSettingsSave() { var importedAssets = new string[1]; var deletedAssets = new string[0]; var movedAssets = new string[0]; var movedFromAssetPaths = new string[0]; var entry = Settings.CreateOrMoveEntry(m_AssetGUID, Settings.groups[0]); var prevTestObjName = entry.MainAsset.name; entry.MainAsset.name = "test"; importedAssets[0] = ConfigFolder + "/test.prefab"; EditorUtility.ClearDirty(Settings); var prevDC = EditorUtility.GetDirtyCount(Settings); Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Assert.AreEqual(prevDC, EditorUtility.GetDirtyCount(Settings)); Assert.IsFalse(EditorUtility.IsDirty(Settings)); entry.MainAsset.name = prevTestObjName; }
public void AssetReferenceDrawer_SetMainAssets_SetToNullDirtiesObject() { // Setup var subAssets = new List <Object>(); var atlas = SetUpSpriteAtlas(1, out subAssets); var property = SetupForSetSubAssets(atlas, 1); m_AssetReferenceDrawer.m_label = new GUIContent("testSpriteReference"); FieldInfo propertyFieldInfo = typeof(TestSubObjectsSpriteAtlas).GetField("testSpriteReference", BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance); var assetPath = AssetDatabase.GetAssetOrScenePath(atlas); // Test EditorUtility.ClearDirty(property.serializedObject.targetObject); var prevDirty = EditorUtility.IsDirty(property.serializedObject.targetObject); m_AssetReferenceDrawer.SetMainAssets(property, null, null, propertyFieldInfo); Assert.IsFalse(prevDirty); Assert.IsTrue(EditorUtility.IsDirty(property.serializedObject.targetObject)); }
public void AddressableAssetSettings_OnPostprocessAllAssets_AddAssetEntriesCollectionNotTriggerSettingsSave() { // Setup var importedAssets = new string[1]; var deletedAssets = new string[0]; var movedAssets = new string[0]; var movedFromAssetPaths = new string[0]; var collectionPath = Path.Combine(ConfigFolder, "collection.asset").Replace('\\', '/'); var collection = ScriptableObject.CreateInstance <AddressableAssetEntryCollection>(); var entry = new AddressableAssetEntry("12345698655", "TestAssetEntry", null, false); entry.m_cachedAssetPath = "TestPath"; collection.Entries.Add(entry); AssetDatabase.CreateAsset(collection, collectionPath); importedAssets[0] = collectionPath; EditorUtility.ClearDirty(Settings); var prevDC = EditorUtility.GetDirtyCount(Settings); // Test Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Assert.AreEqual(prevDC, EditorUtility.GetDirtyCount(Settings)); Assert.IsFalse(EditorUtility.IsDirty(Settings)); }
public void AddressableAssetSettings_OnPostprocessAllAssets_DeleteAssetToNullNotTriggerSettingsSave() { // Setup var importedAssets = new string[0]; var deletedAssets = new string[1]; var movedAssets = new string[0]; var movedFromAssetPaths = new string[0]; Settings.groups.Add(null); Settings.DataBuilders.Add(null); Settings.GroupTemplateObjects.Add(null); Settings.InitializationObjects.Add(null); deletedAssets[0] = ""; EditorUtility.ClearDirty(Settings); var prevDC = EditorUtility.GetDirtyCount(Settings); // Test Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Settings.OnPostprocessAllAssets(importedAssets, deletedAssets, movedAssets, movedFromAssetPaths); Assert.AreEqual(prevDC, EditorUtility.GetDirtyCount(Settings)); Assert.IsFalse(EditorUtility.IsDirty(Settings)); }
private void OnEnable() { EditorUtility.ClearDirty(this); }
public override void OnInspectorGUI() { serialized.Update(); EditorGUILayout.BeginVertical(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(10); { int length = (scrollValue * 5 + 5) >= Enum.GetNames(typeof(TerrainType)).Length ? Enum.GetNames(typeof(TerrainType)).Length : (scrollValue * 5 + 5); for (int i = scrollValue * 5; i < length; i++) { GUILayout.Label(((TerrainType)i).ToString()); } } EditorGUILayout.EndHorizontal(); for (int i = 0; i < Enum.GetNames(typeof(TerrainActionType)).Length; i++) { EditorGUILayout.BeginHorizontal(); GUILayout.Label(((TerrainActionType)i).ToString()); int length = (scrollValue * 5 + 5) >= Enum.GetNames(typeof(TerrainType)).Length ? Enum.GetNames(typeof(TerrainType)).Length : (scrollValue * 5 + 5); for (int j = scrollValue * 5; j < length; j++) { int cacheValue = EditorGUILayout.IntField(envirconmentConfig.data[i].terrainMovingValue[j]); if (envirconmentConfig.data[i].terrainMovingValue[j] != cacheValue) { EditorUtility.SetDirty(envirconmentConfig); envirconmentConfig.data[i].terrainMovingValue[j] = cacheValue; } } EditorGUILayout.EndHorizontal(); } { int count = Enum.GetNames(typeof(TerrainType)).Length / 5 + (Enum.GetNames(typeof(TerrainType)).Length % 5 != 0 ? 1 : 0); scrollValue = Convert.ToInt32(GUILayout.HorizontalScrollbar(scrollValue, 1, 0, count)); } { int index = 0; foreach (var v in envirconmentConfig.allTerrainType) { EditorGUILayout.BeginHorizontal(); animBoolArray[index].target = EditorGUILayout.Foldout(animBoolArray[index].target, v.allTerrainType.ToString(), true); //GUILayout.Label(new GUIContent(v.allTerrainType.ToString())); if (GUILayout.Button("+")) { EditorUtility.SetDirty(envirconmentConfig); v.terrainTypeSpriteList.Add(null); animBoolArray[index].target = true; } EditorGUILayout.EndHorizontal(); if (EditorGUILayout.BeginFadeGroup(animBoolArray[index].faded)) { EditorGUILayout.BeginVertical(GUI.skin.box); for (int i = 0; i < v.terrainTypeSpriteList.Count; i++) { EditorGUILayout.BeginHorizontal(); v.terrainTypeSpriteList[i] = EditorGUILayout.ObjectField(v.terrainTypeSpriteList[i], typeof(Sprite), true) as Sprite; if (GUILayout.Button("-")) { EditorUtility.SetDirty(envirconmentConfig); v.terrainTypeSpriteList.Remove(v.terrainTypeSpriteList[i]); } EditorGUILayout.EndHorizontal(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndFadeGroup(); index++; } } if (EditorUtility.IsDirty(envirconmentConfig)) { if (GUILayout.Button("Save")) { EditorSceneManager.SaveScene(SceneManager.GetActiveScene()); AssetDatabase.Refresh(); EditorUtility.ClearDirty(envirconmentConfig); } } EditorGUILayout.EndVertical(); serialized.ApplyModifiedProperties(); }
protected override BuildResult OnBuild(BuildContext context) { SetOuputBuildDirectoryAbsolute(context); var backups = new[] { new UnitySettingsState(UnitySettingsState.PlayerSettingsAsset) }; PrepareContext(context); var scriptingSettings = context.GetComponentOrDefault <ClassicScriptingSettings>(); var targetGroup = UnityEditor.BuildPipeline.GetBuildTargetGroup(context.GetValue <ClassicSharedData>().BuildTarget); // Needed by CompilationPipeline.GetAssemblies(AssembliesType.PlayerWithoutTestAssemblies) in GraphSetupCodeGenertion.cs // If we don't set the scripting backend, GetAssemblies might return assemblies compiled for il2cpp instead of mono, or vice versa PlayerSettings.SetScriptingBackend(targetGroup, scriptingSettings.ScriptingBackend); PlayerSettings.SetIl2CppCompilerConfiguration(targetGroup, scriptingSettings.Il2CppCompilerConfiguration); foreach (var b in backups) { EditorUtility.ClearDirty(b.Target); } try { context.BuildProgress?.Update($"Setting up typedb graph", "", 10); TundraTypeDBDagFor(context).DeleteIfExists(); TundraTypeDBDagJson(context).DeleteIfExists(); var firstTypeDBGraphGenResult = CreateTypeDBTundraGraph(0, context); if (firstTypeDBGraphGenResult.Failed) { return(firstTypeDBGraphGenResult); } context.BuildProgress?.Update($"Executing typedb graph", "", 10); JustTundra(incrementalPassNumber => CreateTypeDBTundraGraph(incrementalPassNumber, context), TundraTypeDBDagFor(context), 0, context); context.BuildProgress?.Update($"Building datafiles", "", 10); using (new ProfilerMarker("DataBuild").Auto()) ExecuteDataBuild(context); context.BuildProgress?.Update($"Setting up full graph", "", 10); //for now, always regenerate the graph. we do not have enough knowledge yet to make a good decision on when it is, and when it is not safe to reuse the previous one. { TundraDag(context).DeleteIfExists(); TundraDagJson(context).DeleteIfExists(); var result = CreateFullTundraGraph(0, context); if (result.Failed) { return(result); } } context.BuildProgress?.Update($"Executing full graph", "", 10); JustTundra((passNumber) => CreateFullTundraGraph(passNumber, context), TundraDag(context), 0, context); return(context.Success()); } finally { foreach (var b in backups) { b.Restore(); } } }