-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9bc1731
commit 4b0f5b5
Showing
15 changed files
with
325 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Collections.Generic; | ||
using UnityEditor; | ||
using UnityEngine; | ||
using Stopwatch = System.Diagnostics.Stopwatch; | ||
|
||
namespace VioletUI { | ||
public class PrefabListener : UnityEditor.AssetModificationProcessor { | ||
static string[] OnWillSaveAssets(string[] paths) { | ||
foreach (var path in paths) { | ||
if (path.Contains(".prefab")) { | ||
UpdateRepeatViews(path); | ||
} | ||
} | ||
return paths; | ||
} | ||
|
||
static void UpdateRepeatViews(string prefabPath) { | ||
IRepeatView repeatView; | ||
HashSet<GameObject> processed = new HashSet<GameObject>(); | ||
|
||
// https://docs.unity3d.com/ScriptReference/Resources.FindObjectsOfTypeAll.html?_ga=2.70405528.968528738.1611110066-121275311.1591173442 | ||
foreach (var go in Resources.FindObjectsOfTypeAll<TidyBehaviour>()) { | ||
// check hideFlags | ||
try { | ||
if (go.hideFlags == HideFlags.NotEditable || go.hideFlags == HideFlags.HideAndDontSave) { | ||
continue; | ||
} | ||
} catch(MissingReferenceException) { continue; } | ||
// ignore unity things that aren't in a scene | ||
if (EditorUtility.IsPersistent(go.transform.root.gameObject)) { continue; } | ||
// ignore TidyBehaviours without RepeatViews and RepeatViews without ViewPrefabs | ||
if ((repeatView = go.GetComponent<IRepeatView>())?.ViewPrefab == null) { continue; } | ||
// ignore gameObjects that aren't in a scene | ||
if (!go.gameObject.scene.path.Contains(".unity")) { continue; } | ||
// ignore gameObjects we've already processed | ||
if (processed.Contains(go.gameObject)) { continue; } | ||
|
||
if (PrefabUtility.GetPrefabAssetPathOfNearestInstanceRoot(repeatView.ViewPrefab) == prefabPath) { | ||
repeatView.RegenerateChildren(); | ||
processed.Add(go.gameObject); | ||
Violet.Log($"Updated RepeatView on {go.gameObject.name}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
using UnityEngine; | ||
|
||
public interface IRepeatView { | ||
void RegenerateChildren(); | ||
GameObject ViewPrefab { get; } | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
// Names are automatically added through ScreenIdGenerator.cs, deletions are done manually :) | ||
namespace VioletUI { | ||
public enum ScreenId { | ||
None = 0, | ||
} | ||
//Names are automatically added through ScreenIdGenerator.cs, deletions are done manually in Assets/Plugins/VioletUI/ScreenIds.json :) | ||
public enum ScreenId { | ||
None = 0, | ||
ScreenA = 1, | ||
ScreenB = 2, | ||
Showhide = 3, | ||
} |
Oops, something went wrong.