Skip to content

Cleanup for Editor Play Mode#14

Merged
mark-beiline merged 4 commits into
devfrom
mark/enter-play-mode
Apr 3, 2023
Merged

Cleanup for Editor Play Mode#14
mark-beiline merged 4 commits into
devfrom
mark/enter-play-mode

Conversation

@mark-beiline
Copy link
Copy Markdown
Collaborator

@mark-beiline mark-beiline commented Feb 28, 2023

Even if we don't support editor mode atm we can still expect the user to enter Play Mode for testing purposes.

Entering Play Mode before this PR shows a few errors. They're benign but look scary:
image

This PR would also make it easier to support editor mode in the future.

@@ -1,4 +1,4 @@
#if UNITY_STANDALONE_WIN && UNITY_64 && !UNITY_EDITOR
#if UNITY_STANDALONE_WIN && UNITY_64
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The graphics init errors are coming from the #if NATIVE_RENDERING_PLUGIN_AVAILABLE (line 71 ) placeholder version of the NativeRenderingPluginNative class.

The solution is to not use the placeholder version in Play Mode.

#endif
}

public virtual void Dispose()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method can be made abstract. This class does not need to inherit IDisposable.


public override void Dispose()
{
foreach (var (_, item) in m_Items)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Curious about why we need this. Doesn't the runtime clean up the textures when the game quits, or when entering play mode (domain reload).

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have not encountered a need for this in any other projects I've seen.

…Unity into mark/enter-play-mode

# Conflicts:
#	DisguiseUnityRenderStream/Runtime/ScratchTextureManager.cs
}

public void Dispose()
protected override void Dispose()
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This a workaround for NativeArray complaining about Dispose() not being called when you perform a domain reload, right? It's super-annoying.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes exactly

@mark-beiline mark-beiline merged commit 254a6da into dev Apr 3, 2023
@mark-beiline mark-beiline deleted the mark/enter-play-mode branch April 3, 2023 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants