-
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.
Merge pull request #160 from Centurion-Creative-Connect/feature/gun-b…
…ullet-preview GunBullet trajectory prediction
- Loading branch information
Showing
10 changed files
with
356 additions
and
52 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
47 changes: 47 additions & 0 deletions
47
...enturioncc.system/Editor/EditorInspector/Gun/DataStore/GunRecoilPatternDataStoreEditor.cs
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,47 @@ | ||
using CenturionCC.System.Editor.Utils; | ||
using CenturionCC.System.Gun.DataStore; | ||
using UdonSharpEditor; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace CenturionCC.System.Editor.EditorInspector.Gun.DataStore | ||
{ | ||
[CustomEditor(typeof(GunRecoilPatternDataStore))] | ||
public class GunRecoilPatternDataStoreEditor : UnityEditor.Editor | ||
{ | ||
private int _maxPatterns; | ||
|
||
private void OnEnable() | ||
{ | ||
_maxPatterns = ((GunRecoilPatternDataStore)target).MaxPatterns; | ||
} | ||
|
||
public override void OnInspectorGUI() | ||
{ | ||
if (UdonSharpGUI.DrawDefaultUdonSharpBehaviourHeader(target)) | ||
return; | ||
|
||
GUILayout.Label("Settings", EditorStyles.boldLabel); | ||
|
||
var so = serializedObject; | ||
var property = so.GetIterator(); | ||
property.NextVisible(true); | ||
while (property.NextVisible(false)) | ||
{ | ||
GUIUtil.FoldoutPropertyField(property, 2); | ||
} | ||
|
||
if (so.ApplyModifiedProperties()) | ||
{ | ||
_maxPatterns = ((GunRecoilPatternDataStore)target).MaxPatterns; | ||
} | ||
|
||
GUILayout.Label("Stats", EditorStyles.boldLabel); | ||
using (new EditorGUI.DisabledGroupScope(true)) | ||
{ | ||
EditorGUILayout.IntField("Max Patterns", _maxPatterns); | ||
EditorGUILayout.HelpBox("Max Patterns does not consider duplicated elements", MessageType.Warning); | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
...ioncc.system/Editor/EditorInspector/Gun/DataStore/GunRecoilPatternDataStoreEditor.cs.meta
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
58 changes: 58 additions & 0 deletions
58
Packages/org.centurioncc.system/Editor/EditorWindow/GunUtilitiesWindow.cs
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,58 @@ | ||
using CenturionCC.System.Editor.EditorInspector.Gun.DataStore; | ||
using CenturionCC.System.Gun.DataStore; | ||
using UnityEditor; | ||
using UnityEngine; | ||
|
||
namespace CenturionCC.System.Editor.EditorWindow | ||
{ | ||
public class GunUtilitiesWindow : UnityEditor.EditorWindow | ||
{ | ||
private GunBulletDataStore _dataStore; | ||
private Transform _shootingRef; | ||
private bool _showPreview; | ||
private bool _showRange; | ||
|
||
private void OnEnable() | ||
{ | ||
SceneView.duringSceneGui += OnDrawPreviewGizmos; | ||
} | ||
|
||
private void OnDisable() | ||
{ | ||
SceneView.duringSceneGui -= OnDrawPreviewGizmos; | ||
} | ||
|
||
private void OnGUI() | ||
{ | ||
_shootingRef = | ||
EditorGUILayout.ObjectField("Shooting Ref", _shootingRef, typeof(Transform), true) as Transform; | ||
_dataStore = | ||
EditorGUILayout.ObjectField("Data Store", _dataStore, typeof(GunBulletDataStore), true) as | ||
GunBulletDataStore; | ||
|
||
_showRange = EditorGUILayout.Toggle("Show Range", _showRange); | ||
_showPreview = EditorGUILayout.Toggle("Show Preview", _showPreview); | ||
} | ||
|
||
[MenuItem("Centurion-Utils/Gun Utilities")] | ||
public static void InitMenu() | ||
{ | ||
GunUtilitiesWindow window = GetWindow<GunUtilitiesWindow>(); | ||
window.titleContent.text = "Gun Utilities"; | ||
window.Show(); | ||
} | ||
|
||
private void OnDrawPreviewGizmos(SceneView sceneView) | ||
{ | ||
if (_shootingRef != null && _showPreview) | ||
{ | ||
GunBulletDataStoreEditor.DrawRange(_shootingRef, Vector3.zero, Quaternion.identity); | ||
} | ||
|
||
if (_shootingRef != null && _dataStore != null && _showPreview) | ||
{ | ||
GunBulletDataStoreEditor.DrawHandles(_shootingRef, Vector3.zero, Quaternion.identity, _dataStore); | ||
} | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
Packages/org.centurioncc.system/Editor/EditorWindow/GunUtilitiesWindow.cs.meta
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
Oops, something went wrong.