Skip to content
This repository was archived by the owner on Jan 9, 2022. It is now read-only.

Commit eb6f1e9

Browse files
committed
Collider enabled
1 parent 91c6290 commit eb6f1e9

12 files changed

+324
-0
lines changed

Editor/Documentation/Collider.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using UnityEditor;
3+
using UnityEngine;
4+
5+
namespace Juce.Feedbacks
6+
{
7+
internal class ColliderSetEnabledDocumentation : IFeedbackDocumentation
8+
{
9+
public Type FeedbackType => typeof(ColliderSetEnabledFeedback);
10+
11+
public void DrawDocumentation()
12+
{
13+
GUILayout.Label("Enables or disables the target Collider", EditorStyles.wordWrappedLabel);
14+
15+
EditorGUILayout.Space(2);
16+
17+
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
18+
{
19+
GUILayout.Label("- Target: Collider that is going to be enabled/disabled", EditorStyles.wordWrappedLabel);
20+
}
21+
22+
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
23+
{
24+
GUILayout.Label("- Set Enabled: enables or disables the Collider", EditorStyles.wordWrappedLabel);
25+
}
26+
27+
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
28+
{
29+
GenericsDocumentation.DelayDocumentation();
30+
}
31+
}
32+
}
33+
}

Editor/Documentation/Collider/ColliderSetEnabledDocumentation.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Editor/Documentation/Collider2D.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System;
2+
using UnityEditor;
3+
using UnityEngine;
4+
5+
namespace Juce.Feedbacks
6+
{
7+
internal class Collider2DSetEnabledDocumentation : IFeedbackDocumentation
8+
{
9+
public Type FeedbackType => typeof(Collider2DSetEnabledFeedback);
10+
11+
public void DrawDocumentation()
12+
{
13+
GUILayout.Label("Enables or disables the target Collider2D", EditorStyles.wordWrappedLabel);
14+
15+
EditorGUILayout.Space(2);
16+
17+
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
18+
{
19+
GUILayout.Label("- Target: Collider2D that is going to be enabled/disabled", EditorStyles.wordWrappedLabel);
20+
}
21+
22+
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
23+
{
24+
GUILayout.Label("- Set Enabled: enables or disables the Collider2D", EditorStyles.wordWrappedLabel);
25+
}
26+
27+
using (new EditorGUILayout.VerticalScope(EditorStyles.helpBox))
28+
{
29+
GenericsDocumentation.DelayDocumentation();
30+
}
31+
}
32+
}
33+
}

Editor/Documentation/Collider2D/Collider2DSetEnabledDocumentation.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Feedbacks/Collider.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
using Juce.Tween;
2+
using System.Collections.Generic;
3+
using UnityEngine;
4+
5+
namespace Juce.Feedbacks
6+
{
7+
[FeedbackIdentifier("Set Enabled", "Collider/")]
8+
public class ColliderSetEnabledFeedback : Feedback
9+
{
10+
[Header(FeedbackSectionsUtils.TargetSection)]
11+
[SerializeField] private Collider target = default;
12+
13+
[Header(FeedbackSectionsUtils.ValuesSection)]
14+
[SerializeField] private bool setEnabled = default;
15+
16+
[Header(FeedbackSectionsUtils.TimingSection)]
17+
[SerializeField] [Min(0)] private float delay = default;
18+
19+
private bool initialEnabledValue;
20+
21+
public Collider Target { get => target; set => target = value; }
22+
public bool SetEnabled { get => setEnabled; set => setEnabled = value; }
23+
public float Delay { get => delay; set => delay = Mathf.Max(0, value); }
24+
25+
public override bool GetFeedbackErrors(out string errors)
26+
{
27+
if (target == null)
28+
{
29+
errors = ErrorUtils.TargetNullErrorMessage;
30+
return true;
31+
}
32+
33+
errors = string.Empty;
34+
return false;
35+
}
36+
37+
public override string GetFeedbackTargetInfo()
38+
{
39+
return target != null ? target.gameObject.name : string.Empty;
40+
}
41+
42+
public override void GetFeedbackInfo(ref List<string> infoList)
43+
{
44+
InfoUtils.GetTimingInfo(ref infoList, delay);
45+
infoList.Add($"Enabled: {setEnabled}");
46+
}
47+
48+
public override void OnFirstTimeExecute()
49+
{
50+
if (target == null)
51+
{
52+
return;
53+
}
54+
55+
initialEnabledValue = target.enabled;
56+
}
57+
58+
public override void OnReset()
59+
{
60+
if (target == null)
61+
{
62+
return;
63+
}
64+
65+
target.enabled = initialEnabledValue;
66+
}
67+
68+
public override ExecuteResult OnExecute(FlowContext context, SequenceTween sequenceTween)
69+
{
70+
if (target == null)
71+
{
72+
return null;
73+
}
74+
75+
Tween.Tween delayTween = null;
76+
77+
if (delay > 0)
78+
{
79+
delayTween = new WaitTimeTween(delay);
80+
sequenceTween.Append(delayTween);
81+
}
82+
83+
sequenceTween.AppendCallback(() => target.enabled = setEnabled);
84+
85+
ExecuteResult result = new ExecuteResult();
86+
result.DelayTween = delayTween;
87+
88+
return result;
89+
}
90+
}
91+
}

Runtime/Feedbacks/Collider/ColliderSetEnabledFeedback.cs.meta

Lines changed: 11 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Feedbacks/Collider2D.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)