Skip to content

Commit 0357855

Browse files
authored
Merge pull request #64 from VirtueSky/dev
Dev
2 parents c605e15 + 36c980c commit 0357855

File tree

7 files changed

+59
-38
lines changed

7 files changed

+59
-38
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
### 1: Download the repository and drop it into folder `Assets`
2424
### 2: Add the line below to `Packages/manifest.json`
2525

26-
for version `3.4.1`
26+
for version `3.4.2`
2727
```json
28-
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.4.1",
28+
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.4.2",
2929
```
3030

3131
## Includes modules

VirtueSky/Component/MoveComponent.cs

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
using System.Collections.Generic;
22
using UnityEngine;
3+
using UnityEngine.Events;
34
using VirtueSky.Core;
45
using VirtueSky.Inspector;
56

@@ -17,6 +18,7 @@ public class MoveComponent : BaseMono
1718
private bool _reverse; // Flag to indicate whether the object should move in reverse
1819
private int _currentPoint; // The current point the object is moving towards
1920
private bool _isMoving = true; // Flag to indicate whether the object is currently moving
21+
public UnityEvent<int> onPointReached; // Unity event to notify when a point is reached
2022

2123
void Start()
2224
{
@@ -40,6 +42,7 @@ public override void Tick()
4042
if (movingObject.transform.position == points[_currentPoint].position)
4143
{
4244
// When the object reaches the point, move on to the next one
45+
onPointReached?.Invoke(_currentPoint);
4346
if (!_reverse)
4447
{
4548
_currentPoint++;
@@ -73,18 +76,17 @@ public void ResumeMoving()
7376
_isMoving = true;
7477
}
7578

76-
// [Button]
77-
// public void ReverseMoving()
78-
// {
79-
// _reverse = !_reverse;
80-
// if (_currentPoint == 0)
81-
// {
82-
// _currentPoint = points.Count - 1;
83-
// }
84-
// else if (_currentPoint == points.Count - 1)
85-
// {
86-
// _currentPoint = 0;
87-
// }
88-
// }
79+
public void ReverseMoving()
80+
{
81+
_reverse = !_reverse;
82+
if (_currentPoint == 0)
83+
{
84+
_currentPoint = points.Count - 1;
85+
}
86+
else if (_currentPoint == points.Count - 1)
87+
{
88+
_currentPoint = 0;
89+
}
90+
}
8991
}
9092
}

VirtueSky/ControlPanel/CPLevelEditorDrawer.cs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -258,16 +258,26 @@ private static void DrawContent(Rect position)
258258
SceneView.RepaintAll();
259259
if (levelEditorTabType == LevelEditorTabType.Setting)
260260
{
261-
InternalDrawDropArea(position);
262-
GUILayout.Space(4);
263-
InternalDrawSetting();
261+
InternalDrawSettingTab(position);
264262
}
265263
else
266264
{
267265
InternalDrawPickupArea(position);
268266
}
269267
}
270268

269+
private static void InternalDrawSettingTab(Rect position)
270+
{
271+
GUILayout.BeginVertical();
272+
LevelSystemEditorSetting.Instance.SettingTabScrollPosition =
273+
GUILayout.BeginScrollView(LevelSystemEditorSetting.Instance.SettingTabScrollPosition);
274+
InternalDrawDropArea(position);
275+
GUILayout.Space(4);
276+
InternalDrawSetting();
277+
GUILayout.EndScrollView();
278+
GUILayout.EndVertical();
279+
}
280+
271281
private static void InternalDrawDropArea(Rect position)
272282
{
273283
Uniform.DrawGroupFoldout("level_editor_drop_area", "Drop Area", DrawDropArea);
@@ -281,10 +291,11 @@ void DrawDropArea()
281291
#region horizontal
282292

283293
EditorGUILayout.BeginHorizontal();
284-
var whiteArea = GUILayoutUtility.GetRect(0.0f, 50f, GUILayout.ExpandWidth(true));
285-
var blackArea = GUILayoutUtility.GetRect(0.0f, 50f, GUILayout.ExpandWidth(true));
294+
float widthArea = (float)(position.width - ConstantControlPanel.POSITION_X_START_CONTENT) / 2 - 5;
295+
var whiteArea = GUILayoutUtility.GetRect(widthArea, 50f, GUILayout.ExpandWidth(true));
296+
var blackArea = GUILayoutUtility.GetRect(widthArea, 50f, GUILayout.ExpandWidth(true));
286297
// ReSharper disable once CompareOfFloatsByEqualityOperator
287-
if (whiteArea.width == 1f) width = (position.width - ConstantControlPanel.POSITION_X_START_CONTENT) / 2;
298+
if (whiteArea.width == 1f) width = widthArea;
288299
else width = whiteArea.width;
289300
GUI.backgroundColor = new Color(0f, 0.83f, 1f);
290301
GUI.Box(whiteArea, "[WHITE LIST]",
@@ -725,7 +736,7 @@ void DrawPickupArea()
725736
}
726737
else
727738
{
728-
height -= 342;
739+
// height -= 342;
729740
}
730741
}
731742
else
@@ -764,7 +775,6 @@ void DrawPickupArea()
764775
}
765776

766777
var h = position.height + height;
767-
768778
LevelSystemEditorSetting.Instance.PickObjectScrollPosition =
769779
GUILayout.BeginScrollView(LevelSystemEditorSetting.Instance.PickObjectScrollPosition,
770780
GUILayout.Height(h));

VirtueSky/ControlPanel/ConstantPackage.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
{
33
public class ConstantPackage
44
{
5-
public const string VersionSunflower = "3.4.1";
5+
public const string VersionSunflower = "3.4.2";
66
public const string PackageNameInAppPurchase = "com.unity.purchasing";
77
public const string MaxVersionInAppPurchase = "4.12.2";
88
public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json";
@@ -96,7 +96,7 @@ public class ConstantPackage
9696
public const string PackageNameCoffeeUIEffect = "com.coffee.ui-effect";
9797

9898
public const string MaxVersionCoffeeUIEffect =
99-
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.9.5";
99+
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.9.6";
100100

101101
public const string PackageNameCoffeeUIParticle = "com.coffee.ui-particle";
102102

VirtueSky/LevelEditor/LevelSystemEditorSetting.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
using System;
22
using System.Collections.Generic;
3-
using System.IO;
43
using UnityEditor;
54
using UnityEngine;
6-
using UnityEngine.Serialization;
7-
using VirtueSky.UtilsEditor;
85
using VirtueSky.Utils;
96

107
namespace VirtueSky.LevelEditor
@@ -17,7 +14,8 @@ public class LevelSystemEditorSetting : ScriptableSettings<LevelSystemEditorSett
1714
public readonly string[] optionsSpawn = { "Default", "Index", "Custom" };
1815
public readonly string[] optionsMode = { "Renderer", "Ignore" };
1916

20-
public Vector2 PickObjectScrollPosition { get; set; }
17+
public Vector2 SettingTabScrollPosition { get; set; } = Vector2.zero;
18+
public Vector2 PickObjectScrollPosition { get; set; } = Vector2.zero;
2119
public Vector2 WhitelistScrollPosition { get; set; }
2220
public Vector2 BlacklistScrollPosition { get; set; }
2321
public PickObject CurrentPickObject { get; set; }

VirtueSky/Utils/Editor/EditorGeneric.cs

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,20 @@ public static bool Get2DMouseScenePosition(out Vector2 result)
2222
result = Vector2.zero;
2323

2424
var cam = Camera.current;
25-
var mp = Event.current.mousePosition;
26-
mp.y = cam.pixelHeight - mp.y;
27-
var ray = cam.ScreenPointToRay(mp);
25+
if (cam == null) return false;
26+
27+
var guiMouse = Event.current.mousePosition;
28+
var pixelMouse = guiMouse * EditorGUIUtility.pixelsPerPoint;
29+
pixelMouse.y = cam.pixelHeight - pixelMouse.y; // không dùng Screen.height!
30+
31+
var ray = cam.ScreenPointToRay(pixelMouse);
2832
if (ray.direction != Vector3.forward) return false;
2933

3034
result = ray.origin;
3135
return true;
3236
}
3337

38+
3439
/// <summary>
3540
/// Render an object on sceneView using sprite renderers
3641
/// </summary>
@@ -132,7 +137,8 @@ public static bool CalculateBounds(
132137

133138
var rendererBounds = renderer.bounds;
134139

135-
rendererBounds.SetMinMax(root.transform.InverseTransformPoint(rendererBounds.min), root.transform.InverseTransformPoint(rendererBounds.max));
140+
rendererBounds.SetMinMax(root.transform.InverseTransformPoint(rendererBounds.min),
141+
root.transform.InverseTransformPoint(rendererBounds.max));
136142

137143
if (first)
138144
{
@@ -164,7 +170,8 @@ public static bool CalculateBounds(
164170

165171
var meshBounds = mesh.bounds;
166172

167-
meshBounds.SetMinMax(root.transform.InverseTransformPoint(meshFilter.transform.TransformPoint(meshBounds.min)),
173+
meshBounds.SetMinMax(
174+
root.transform.InverseTransformPoint(meshFilter.transform.TransformPoint(meshBounds.min)),
168175
root.transform.InverseTransformPoint(meshFilter.transform.TransformPoint(meshBounds.max)));
169176

170177
if (first)
@@ -226,7 +233,8 @@ public static bool CalculateBounds(
226233

227234
var colliderBounds = collider.bounds;
228235

229-
colliderBounds.SetMinMax(root.transform.InverseTransformPoint(colliderBounds.min), root.transform.InverseTransformPoint(colliderBounds.max));
236+
colliderBounds.SetMinMax(root.transform.InverseTransformPoint(colliderBounds.min),
237+
root.transform.InverseTransformPoint(colliderBounds.max));
230238

231239
if (first)
232240
{
@@ -293,7 +301,8 @@ public static bool CalculateBounds(
293301

294302
var meshBounds = mesh.bounds;
295303

296-
meshBounds.SetMinMax(root.transform.TransformPoint(meshBounds.min), root.transform.TransformPoint(meshBounds.max));
304+
meshBounds.SetMinMax(root.transform.TransformPoint(meshBounds.min),
305+
root.transform.TransformPoint(meshBounds.max));
297306

298307
if (first)
299308
{
@@ -454,7 +463,9 @@ public static void DrawSerializationError(Type type, Rect position = default)
454463
{
455464
if (position == default)
456465
{
457-
EditorGUILayout.HelpBox($"{type} is not marked as Serializable," + "\n Add [System.Serializable] attribute.", MessageType.Error);
466+
EditorGUILayout.HelpBox(
467+
$"{type} is not marked as Serializable," + "\n Add [System.Serializable] attribute.",
468+
MessageType.Error);
458469
}
459470
else
460471
{

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "com.virtuesky.sunflower",
33
"displayName": "Sunflower",
44
"description": "Core ScriptableObject Architecture for building Unity games",
5-
"version": "3.4.1",
5+
"version": "3.4.2",
66
"unity": "2022.3",
77
"category": "virtuesky",
88
"license": "MIT",

0 commit comments

Comments
 (0)