Skip to content

Commit

Permalink
Merge pull request Kellojo#15 from GameArki/master
Browse files Browse the repository at this point in the history
<feature> Smoothly Moving Brush; <bugfix> ctrl+z bug
  • Loading branch information
Kellojo authored Sep 24, 2023
2 parents 041fa7f + ee8409b commit fd8352e
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions Assets/GameObjectBrush/Scripts/Editor/GameObjectBrushEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,24 @@ void OnEnable() {
brushes = lastUsedBCollInfo.Value;

//add thene delegate
#if UNITY_2021_1_OR_NEWER
SceneView.duringSceneGui += OnSceneGUI;
#else
SceneView.onSceneGUIDelegate += OnSceneGUI;
#endif
Instance = this;
this.autoRepaintOnSceneChange = true;
}
void OnDestroy() {
if (brushes != null) {
brushes.Save();
}
//remove the delegate
#if UNITY_2021_1_OR_NEWER
SceneView.duringSceneGui -= OnSceneGUI;
#else
SceneView.onSceneGUIDelegate -= OnSceneGUI;
#endif
}
void OnGUI() {

Expand Down Expand Up @@ -403,6 +412,7 @@ void OnSceneGUI(SceneView sceneView) {
}
}
}
sceneView.Repaint();
}


Expand Down Expand Up @@ -654,8 +664,10 @@ public static GameObject[] GetAllChildren(GameObject obj) {
public static bool arePositionsWithinRange(Dictionary<GameObject, Vector3> positions, Vector3 point, float range, float density) {
var values = positions.Values;
float adjustedRange = (float) range / density;
foreach(Vector3 position in values) {
if (Vector3.Distance(position, point) <= adjustedRange) {
foreach(var kv in positions) {
var go = kv.Key;
var position = kv.Value;
if (go != null && Vector3.Distance(position, point) <= adjustedRange) {
return true;
}
}
Expand Down

0 comments on commit fd8352e

Please sign in to comment.