public override void OnInspectorGUI() { DrawDefaultInspector(); EditorGUI.BeginChangeCheck(); NodeGenerator nodeGenerator = (NodeGenerator)target; if (GUILayout.Button("Find Neighbours")) { nodeGenerator.GetEdges(); } if (GUILayout.Button("Delete All Connections")) { nodeGenerator.DeleteAllConnections(); } if (EditorGUI.EndChangeCheck()) { serializedObject.ApplyModifiedProperties(); if (!Application.isPlaying) { EditorUtility.SetDirty(target); Node[] nodes = FindObjectsOfType <Node>(); foreach (Node n in nodes) { EditorUtility.SetDirty(n); } EditorApplication.MarkSceneDirty(); } } }
public static void SetDirty(UnityObject target, bool delayed = false, bool forced = false) { if (Application.isPlaying) { return; } if (target.IsNull()) { return; } if (delayed) { if (!Utility.delayedDirty.Contains(target)) { Events.AddLimited("On Enter Play", () => Utility.SetDirty(target), 1); Events.AddLimited("On Enter Play", Utility.ClearDirty, 1); Utility.delayedDirty.AddNew(target); } return; } EditorUtility.SetDirty(target); #if UNITY_5_3_OR_NEWER UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty(); #else EditorApplication.MarkSceneDirty(); #endif //Utility.UpdatePrefab(target); }
static void CancelMapper() { Scene scene = SceneManager.GetActiveScene(); GameObject[] rootObjects = scene.GetRootGameObjects(); List <PanoramaBlock> panoramaBlocks = new List <PanoramaBlock>(); foreach (var go in rootObjects) { if (go.activeInHierarchy == false) { continue; } panoramaBlocks.AddRange(go.GetComponentsInChildren <PanoramaBlock>(false)); } foreach (var mc in panoramaBlocks) { if (mc.gameObject.activeInHierarchy == false) { continue; } mc.CancelBundle(); } var path = GetAssetBundleLoadingPath(); DeleteDirectory(path); EditorApplication.MarkSceneDirty(); EditorApplication.SaveScene(); AssetDatabase.SaveAssets(); }
public override void OnInspectorGUI() { serializedObject.Update(); UIPainter panel = target as UIPainter; DrawPropertiesExcluding(serializedObject, propertyToExclude); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Package Name"); if (GUILayout.Button(packageName.stringValue, "ObjectField")) { EditorWindow.GetWindow <PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue); } if (GUILayout.Button("Clear", GUILayout.Width(50))) { #if UNITY_2018_3_OR_NEWER bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab; #else bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab; #endif panel.SendMessage("OnUpdateSource", new object[] { null, null, null, !isPrefab }); #if UNITY_5_3_OR_NEWER EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); #elif UNITY_5 EditorApplication.MarkSceneDirty(); #else EditorUtility.SetDirty(panel); #endif } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel("Component Name"); if (GUILayout.Button(componentName.stringValue, "ObjectField")) { EditorWindow.GetWindow <PackagesWindow>(true, "Select a UI Component").SetSelection(packageName.stringValue, componentName.stringValue); } EditorGUILayout.EndHorizontal(); int oldSortingOrder = panel.sortingOrder; EditorGUILayout.PropertyField(sortingOrder); EditorGUILayout.PropertyField(renderCamera); EditorGUILayout.PropertyField(fairyBatching); EditorGUILayout.PropertyField(touchDisabled); if (serializedObject.ApplyModifiedProperties()) { #if UNITY_2018_3_OR_NEWER bool isPrefab = PrefabUtility.GetPrefabAssetType(panel) != PrefabAssetType.NotAPrefab; #else bool isPrefab = PrefabUtility.GetPrefabType(panel) == PrefabType.Prefab; #endif if (!isPrefab) { panel.ApplyModifiedProperties(sortingOrder.intValue != oldSortingOrder); } } }
// Draw the whole inspector public override void OnInspectorGUI() { var localization = (LeanLocalization)target; EditorGUILayout.Separator(); EditorGUILayout.PropertyField(serializedObject.FindProperty("CurrentLanguage")); EditorGUILayout.Separator(); DrawLanguages(localization); EditorGUILayout.Separator(); EditorGUILayout.Separator(); DrawPhrases(localization); EditorGUILayout.Separator(); // Update if dirty? if (serializedObject.ApplyModifiedProperties() == true || dirty == true) { dirty = false; LeanLocalization.UpdateTranslations(); EditorUtility.SetDirty(localization); EditorApplication.MarkSceneDirty(); } }
public static void AssetToName() { Scene scene = SceneManager.GetActiveScene(); GameObject[] rootObjects = scene.GetRootGameObjects(); List <SelectorUIItem> selectorUIs = new List <SelectorUIItem>(); foreach (var go in rootObjects) { if (go.activeInHierarchy == false) { continue; } selectorUIs.AddRange(go.GetComponentsInChildren <SelectorUIItem>(false)); } foreach (var l in selectorUIs) { if (l.gameObject.activeInHierarchy == false) { continue; } l.UnloadAsset(); } EditorApplication.MarkSceneDirty(); EditorApplication.SaveScene(); AssetDatabase.SaveAssets(); }
static void AddButtonClickDelay() { List <ResultItem> listResult = TraverseAllPrefabsForComponent("Button"); Debug.Log(string.Format("Found prefab items '{0}': {1}", "Button", listResult.Count)); foreach (ResultItem trans in listResult) { if (trans.transform.gameObject.GetComponent <ButtonClickDelay>() == null) { Debug.Log(trans.transform.gameObject + " is missing ButtonClickDelay in " + trans.path); trans.transform.gameObject.AddComponent <ButtonClickDelay>(); AssetDatabase.SaveAssets(); } } listResult = TraverseAllScenesForComponent("Button"); Debug.Log(string.Format("Found scene items '{0}': {1}", "Button", listResult.Count)); foreach (ResultItem trans in listResult) { if (trans.transform.gameObject.GetComponent <ButtonClickDelay>() == null) { Debug.Log(trans.transform.gameObject + " is missing ButtonClickDelay in " + trans.path); trans.transform.gameObject.AddComponent <ButtonClickDelay>(); } } EditorApplication.MarkSceneDirty(); }
static void ChangeFont() { List <ResultItem> listResult = TraverseAllPrefabsForComponent("Text"); Debug.Log(string.Format("Found prefab items '{0}': {1}", "Text", listResult.Count)); foreach (ResultItem trans in listResult) { Text text = trans.transform.gameObject.GetComponent <Text>(); if (text != null) { ChangeFontProcess(text, trans); EditorUtility.SetDirty(trans.prefab); } } AssetDatabase.SaveAssets(); listResult = TraverseAllScenesForComponent("Text"); Debug.Log(string.Format("Found scene items '{0}': {1}", "Text", listResult.Count)); foreach (ResultItem trans in listResult) { Text text = trans.transform.gameObject.GetComponent <Text>(); if (text != null) { ChangeFontProcess(text, trans); } } EditorApplication.MarkSceneDirty(); }
static void FindMissingAudio() { string _search = "ButtonClickAudio"; List <ResultItem> listResult = TraverseAllPrefabsForComponent(_search); Debug.Log(string.Format("Found prefab items '{0}': {1}", _search, listResult.Count)); foreach (ResultItem trans in listResult) { ButtonClickAudio _comp = trans.transform.gameObject.GetComponent <ButtonClickAudio>(); if (_comp != null && _comp.audioClip == null) { Debug.Log(trans.transform.gameObject.transform.parent.gameObject + " is missing AudioClip in " + trans.path); } } listResult = TraverseAllScenesForComponent(_search); Debug.Log(string.Format("Found scene items '{0}': {1}", _search, listResult.Count)); foreach (ResultItem trans in listResult) { ButtonClickAudio _comp = trans.transform.gameObject.GetComponent <ButtonClickAudio>(); if (_comp != null && _comp.audioClip == null) { Debug.Log(trans.transform.gameObject.transform.parent.gameObject + " is missing AudioClip in " + trans.path); } } EditorApplication.MarkSceneDirty(); }
private void DrawMissingDataCreation() { if (ErrorDrawer.IsDataMissing(Manager)) { EditorGUILayout.BeginVertical(); if (!ErrorDrawer.IsAllDataMissing(Manager)) { EditorGUILayout.HelpBox("Some or all project data is missing. This may be because of new project data is required in this version of InAudio", MessageType.Warning, true); if (GUILayout.Button("Create missing content", GUILayout.Height(30))) { MissingDataHelper.CreateIfMissing(Manager); Manager.ForceLoad(); #if !UNITY_5_2 EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); EditorSceneManager.SaveCurrentModifiedScenesIfUserWantsTo(); #else EditorApplication.MarkSceneDirty(); EditorApplication.SaveCurrentSceneIfUserWantsTo(); #endif } } DrawStartFromScratch(); EditorGUILayout.EndVertical(); } }
static void CleanBuilt() { Scene scene = SceneManager.GetActiveScene(); GameObject[] rootObjects = scene.GetRootGameObjects(); List <PanoramaBlock> panoramaBlocks = new List <PanoramaBlock>(); foreach (var go in rootObjects) { if (go.activeInHierarchy == false) { continue; } panoramaBlocks.AddRange(go.GetComponentsInChildren <PanoramaBlock>(false)); } foreach (var mc in panoramaBlocks) { if (mc.gameObject.activeInHierarchy == false) { continue; } mc.BreakLink(); } EditorApplication.MarkSceneDirty(); EditorApplication.SaveScene(); AssetDatabase.SaveAssets(); }
//[MenuItem("Optimize Tools/ImageLoader:Cancel Mapper")] public static void CancelMapper() { Scene scene = SceneManager.GetActiveScene(); GameObject[] rootObjects = scene.GetRootGameObjects(); List <ImageLoader> imageLoaders = new List <ImageLoader>(); foreach (var go in rootObjects) { if (go.activeInHierarchy == false) { continue; } imageLoaders.AddRange(go.GetComponentsInChildren <ImageLoader>(false)); } foreach (var l in imageLoaders) { if (l.gameObject.activeInHierarchy == false) { continue; } l.LoadResources(); } EditorApplication.MarkSceneDirty(); EditorApplication.SaveScene(); AssetDatabase.SaveAssets(); }
public override void OnInspectorGUI() { var script = (AssertionComponent)target; EditorGUILayout.BeginHorizontal(); var obj = DrawComparerSelection(script); script.checkMethods = (CheckMethod)EditorGUILayout.EnumMaskField(script.checkMethods, EditorStyles.popup, GUILayout.ExpandWidth(false)); EditorGUILayout.EndHorizontal(); if (script.IsCheckMethodSelected(CheckMethod.AfterPeriodOfTime)) { DrawOptionsForAfterPeriodOfTime(script); } if (script.IsCheckMethodSelected(CheckMethod.Update)) { DrawOptionsForOnUpdate(script); } if (obj) { EditorGUILayout.Space(); m_ThisPathSelector.Draw(script.Action.go, script.Action, script.Action.thisPropertyPath, script.Action.GetAccepatbleTypesForA(), go => { script.Action.go = go; AssertionExplorerWindow.Reload(); }, s => { script.Action.thisPropertyPath = s; AssertionExplorerWindow.Reload(); }); EditorGUILayout.Space(); DrawCustomFields(script); EditorGUILayout.Space(); if (script.Action is ComparerBase) { DrawCompareToType(script.Action as ComparerBase); } } if (GUI.changed) { #if UNITY_5_3_OR_NEWER EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); #else EditorApplication.MarkSceneDirty(); #endif } }
/// <summary> /// Called when the inspector needs to draw /// </summary> public override void OnInspectorGUI() { // Pulls variables from runtime so we have the latest values. mTargetSO.Update(); GUILayout.Space(5); EditorHelper.DrawInspectorTitle("ootii Basic Attributes"); EditorHelper.DrawInspectorDescription("Allows us to assign attributes to game objects.", MessageType.None); GUILayout.Space(5); EditorGUILayout.LabelField("Attributes", EditorStyles.boldLabel, GUILayout.Height(16f)); GUILayout.BeginVertical(EditorHelper.GroupBox); mItemList.DoLayoutList(); if (mItemList.index >= 0) { GUILayout.Space(5f); GUILayout.BeginVertical(EditorHelper.Box); bool lListIsDirty = DrawItemDetail(mTarget.Items[mItemList.index]); if (lListIsDirty) { mIsDirty = true; } GUILayout.EndVertical(); } EditorGUILayout.EndVertical(); GUILayout.Space(5); // If there is a change... update. if (mIsDirty) { // Flag the object as needing to be saved EditorUtility.SetDirty(mTarget); #if UNITY_4_0 || UNITY_4_0_1 || UNITY_4_1 || UNITY_4_2 || UNITY_4_3 || UNITY_4_4 || UNITY_4_5 || UNITY_4_6 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 EditorApplication.MarkSceneDirty(); #else if (!EditorApplication.isPlaying) { UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); } #endif // Pushes the values back to the runtime so it has the changes mTargetSO.ApplyModifiedProperties(); // Clear out the dirty flag mIsDirty = false; } }
public void MarkSceneDirty() { #if UNITY_5_3 EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); #else EditorApplication.MarkSceneDirty(); #endif }
public static void Editor_MarkSceneDirty() { #if UNITY_5_3 || UNITY_5_3_OR_NEWER UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEngine.SceneManagement.SceneManager.GetActiveScene()); #else EditorApplication.MarkSceneDirty(); #endif }
protected void MarkSceneDirty() { #if UNITY_5_3_OR_NEWER EditorSceneManager.MarkAllScenesDirty(); #else EditorApplication.MarkSceneDirty(); #endif }
public static void MarkSceneDirty() { #if UNITY_5_0_TO_5_2 EditorApplication.MarkSceneDirty(); #elif UNITY_5_3_PLUS EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); #endif }
public static void MarkSceneDirty() { #if UNITY_5_3_OR_NEWER UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty(); #else EditorApplication.MarkSceneDirty(); #endif }
public static void MarkActiveSceneDirty() { #if (UNITY_5_0 || UNITY_5_1 || UNITY_5_2) EditorApplication.MarkSceneDirty(); #else UnityEngine.SceneManagement.Scene activeScene = UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene(); UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(activeScene); #endif }
public static void MarkSceneDirty() { #if UNITY_5 && UNITY_EDITOR if (!EditorApplication.isSceneDirty) { EditorApplication.MarkSceneDirty(); } #endif }
/// <summary> /// Update the render mesh and mesh collider of all tile chunks. This should be called once after making all modifications to the tilemap with SetTileData. /// </summary> public void UpdateMeshImmediate() { #if UNITY_EDITOR if (!Application.isPlaying && m_markSceneDirtyOnNextUpdateMesh) { m_markSceneDirtyOnNextUpdateMesh = false; #if UNITY_5_3 || UNITY_5_3_OR_NEWER UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty(); #else EditorApplication.MarkSceneDirty(); #endif } #endif RecalculateMapBounds(); List <TilemapChunk> chunkList = new List <TilemapChunk>(m_dicChunkCache.Values.Count); foreach (TilemapChunk chunk in m_dicChunkCache.Values) { if (chunk) { if (!chunk.UpdateMesh()) { #if UNITY_EDITOR if (IsUndoEnabled) { Undo.DestroyObjectImmediate(chunk.gameObject); } else { DestroyImmediate(chunk.gameObject); } #else DestroyImmediate(chunk.gameObject); #endif } else { //chunk.UpdateColliderMesh(); chunkList.Add(chunk); } } } if (m_autoShrink) { ShrinkMapBoundsToVisibleArea(); } // UpdateColliderMesh is called after calling UpdateMesh of all tilechunks, because UpdateColliderMesh needs the tileId to be updated // ( remember a brush sets neighbours tile id to empty, so UpdateColliderMesh won't be able to know the collider type ) for (int i = 0; i < chunkList.Count; ++i) { chunkList[i].UpdateColliders(); } }
public static void Bootstrap() { BakeNavMesh(); BakeOcclusion(); DeleteEmptyAnimators(); OptimizeScene(); EditorApplication.MarkSceneDirty(); AssetDatabase.SaveAssets(); AssetDatabase.SaveAssets(); }
private static void SetDirty(Object target) { EditorUtility.SetDirty(target); #if UNITY_4 || UNITY_5_0 || UNITY_5_1 || UNITY_5_2 EditorApplication.MarkSceneDirty(); #else UnityEditor.SceneManagement.EditorSceneManager.MarkAllScenesDirty(); #endif }
void ApplyChange() { #if UNITY_5_3_OR_NEWER EditorSceneManager.MarkSceneDirty(EditorSceneManager.GetActiveScene()); #elif UNITY_5 EditorApplication.MarkSceneDirty(); #else EditorUtility.SetDirty(Selection.activeGameObject); #endif }
void Update() { if (tileSelected) { //keeps the native editor tools from interfering on the painter Tools.current = Tool.None; if (gizmoCursor != null) { gizmoCursor.transform.position = new Vector2(Mathf.RoundToInt(mousePos.x) + (GameConstants.gridBlockWidth / 2), Mathf.RoundToInt(mousePos.y) - (GameConstants.gridBlockHeight / 2)); } if (gizmoTile != null) { //Positions the gizmo on the right offset from the cursor Transform ehb = selectedObject.transform.Find("EditorHitbox"); if (ehb != null) { BoxCollider2D Tbx2d = ehb.GetComponent <BoxCollider2D>(); if (Tbx2d.size.x > GameConstants.gridBlockWidth) { offsetX = Tbx2d.size.x / 2 - (GameConstants.gridBlockWidth / 2); } else { offsetX = 0; } if (Tbx2d.size.y > GameConstants.gridBlockHeight) { offsetY = Tbx2d.size.y / 2 - (GameConstants.gridBlockHeight / 2); } else { offsetY = 0; } if (horizontal) { gizmoTile.transform.position = new Vector2(gizmoCursor.transform.position.x + offsetX, gizmoCursor.transform.position.y - offsetY); } else { gizmoTile.transform.position = new Vector2(gizmoCursor.transform.position.x + offsetY, gizmoCursor.transform.position.y - offsetX); } } } EditorApplication.MarkSceneDirty(); } else { Tools.current = lastTool; } if (!windowIsOpen) { this.Close(); } }
static public void MarkSceneDirty() { #if UNITY_5_X #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 || UNITY_5_3 EditorApplication.MarkSceneDirty(); #else EditorSceneManager.MarkSceneDirty(SceneManager.GetActiveScene()); #endif #else EditorApplication.MarkSceneDirty(); #endif }
// public static string GetCurrentSceneGUID() // { // string currentScenePath = EditorApplication.currentScene; // if(!string.IsNullOrEmpty(currentScenePath)) // { // return AssetDatabase.AssetPathToGUID(currentScenePath); // } // else // { // // Scene hasn't been saved // return null; // } // } public static void SetDirty(Object targetObject) { EditorUtility.SetDirty(targetObject); #if UNITY_5_0 || UNITY_5_1 || UNITY_5_2 // As of Unity 5, SetDirty no longer marks the scene as dirty. Need to use the new call for that. EditorApplication.MarkSceneDirty(); #else // 5.3 and above introduce multiple scene management via EditorSceneManager Scene activeScene = EditorSceneManager.GetActiveScene(); EditorSceneManager.MarkSceneDirty(activeScene); #endif }
private void UpdateLine() { vline.Draw(); drawStart = vline.drawStart; drawEnd = vline.drawEnd; EditorUtility.SetDirty(vobject); #if UNITY_5_2 EditorApplication.MarkSceneDirty(); #else UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEditor.SceneManagement.EditorSceneManager.GetActiveScene()); #endif }
private static void MarkDirty(HBAO hbao) { EditorUtility.SetDirty(hbao); if (!EditorApplication.isPlaying) { #if (UNITY_5_2 || UNITY_5_1 || UNITY_5_0) EditorApplication.MarkSceneDirty(); #else UnityEditor.SceneManagement.EditorSceneManager.MarkSceneDirty(UnityEngine.SceneManagement.SceneManager.GetActiveScene()); #endif } }