Skip to content
This repository has been archived by the owner on Feb 11, 2024. It is now read-only.

Fixed Unity 2019 having no GUI among other issues. #235

Merged
merged 4 commits into from
Nov 26, 2019

Conversation

Henry00IS
Copy link
Collaborator

@Henry00IS Henry00IS commented Nov 26, 2019

This commit fixes #234 and #233 and provides complete Unity 2019 support.

  • The !UNITY_2018_OR_NEWER was replaced by !UNITY_2018_1_OR_NEWER that 2019 recognizes properly.
  • SceneView.onSceneGUIDelegate has been replaced by SceneView.duringSceneGui.
  • UnityEditor.StaticEditorFlags.LightmapStatic has been replaced by UnityEditor.StaticEditorFlags.ContributeGI.
  • sceneView.m_SceneLighting has been replaced by sceneView.sceneLighting.
  • SceneView.SceneViewState.Toggle has been replaced by SceneView.SceneViewState.SetAllEnabled.

EditorHelper.SceneViewHasDelegate has been deprecated. SceneView.duringSceneGui is an event and C# enforces that it can only be mentioned in conjunction with a += or -= operator. In order to determine whether we are already subscribed I decided to create a boolean with the [NonSerialized] flag to ensure that any script recompilations will reset it.

Essentially this:

/// <summary>
/// Used to determined whether we are subscribed to the "During scene GUI" event.
/// Recompilations will reset this variable to false and we can rebind.
/// </summary>
[NonSerialized]
private bool isSubscribedToDuringSceneGui = false;

if (!isSubscribedToDuringSceneGui)
{
    // Then resubscribe and repaint
    isSubscribedToDuringSceneGui = true;
    SceneView.duringSceneGui += OnSceneGUI;
    SceneView.RepaintAll();
}

I tested this new code on Unity 5.3, 2017, 2018 and 2019. Works perfectly.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant