-
-
Notifications
You must be signed in to change notification settings - Fork 178
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 #660 from NordlightPer/fix/set_prefab_back_to_acti…
…ve_on_exception Added test and fix for when a game object throws during instantiation
- Loading branch information
Showing
4 changed files
with
61 additions
and
8 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
VContainer/Assets/Tests/Unity/Fixtures/CrashingSampleMonoBehaviour.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,29 @@ | ||
using System; | ||
using UnityEngine; | ||
|
||
namespace VContainer.Tests.Unity | ||
{ | ||
|
||
public sealed class CrashingSampleMonoBehaviour : MonoBehaviour, IComponent | ||
{ | ||
public ServiceA ServiceA; | ||
public ServiceA ServiceAInAwake; | ||
public bool StartCalled; | ||
public int UpdateCalls; | ||
|
||
void Start() => StartCalled = true; | ||
void Update() => UpdateCalls += 1; | ||
|
||
void Awake() | ||
{ | ||
ServiceAInAwake = ServiceA; | ||
} | ||
|
||
[Inject] | ||
public void Construct(ServiceA serviceA) | ||
{ | ||
ServiceA = serviceA; | ||
throw new Exception("Something broke during construct"); | ||
} | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
VContainer/Assets/Tests/Unity/Fixtures/CrashingSampleMonoBehaviour.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