Skip to content

Commit

Permalink
Merge pull request #10 from nicollasricas/dev
Browse files Browse the repository at this point in the history
fix: 🐛 Fixed component caching
  • Loading branch information
nicollasricas authored Jan 23, 2022
2 parents 7c7caa4 + 61d7275 commit a787c2b
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 18 deletions.
Binary file not shown.
30 changes: 14 additions & 16 deletions UnityStreamDeck/StreamDeckLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
using UnityEditor;
using UnityEditorInternal;
using UnityEngine;
using UnityEngine.XR;
using WebSocketSharp;
using WebSocketSharp.Net;

Expand Down Expand Up @@ -38,9 +37,7 @@ private void Initialize()
{
configuration.ConfigurationChanged += Configuration_ConfigurationChanged;

var unityVersion = InternalEditorUtility.GetUnityVersion();

if (unityVersion.Major > 2019 || (unityVersion.Major == 2019 && unityVersion.Minor >= 1))
if (InternalEditorUtility.GetUnityVersion().CompareTo(new Version(2019, 1)) >= 0)
{
sceneViewPath = "Window/General/Scene";
gameViewPath = "Window/General/Game";
Expand Down Expand Up @@ -175,16 +172,22 @@ private void HandleStreamDeckConnection()

private void CacheComponents()
{
#if UNITY_2019_2_OR_NEWER
Log("Caching components...");
if (InternalEditorUtility.GetUnityVersion().CompareTo(new Version(2019, 2)) >= 0)
{
Log("Caching components...");

components.Clear();
components.Clear();

foreach (var type in TypeCache.GetTypesDerivedFrom<Component>())
{
components[type.Name.ToLower()] = type;
foreach (Type type in TypeCache.GetTypesDerivedFrom<Component>())
{
if (configuration.Debug)
{
Log($"Cached component {type.Name}", ignoreVerbose: true);
}

components[type.Name.ToLower()] = type;
}
}
#endif
}

private void HandleMessages()
Expand Down Expand Up @@ -300,11 +303,6 @@ private void ToggleSceneGame(ToggleSceneGameMessage message)
}
}

public void ToggleEditorSettings(string X, object value)
{
XRSettings.enabled = true;
}

public void ToggleObjectState(ToggleObjectStateMessage message)
{
foreach (GameObject gameObject in Selection.gameObjects)
Expand Down
2 changes: 1 addition & 1 deletion UnityStreamDeck/StreamDeckLinkConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ private void Load()
ServerHost = EditorPrefs.GetString(GetPrefsFullName(nameof(ServerHost)), "127.0.0.1");
ServerPort = EditorPrefs.GetInt(GetPrefsFullName(nameof(ServerPort)), 18084);
Enabled = EditorPrefs.GetBool(GetPrefsFullName(nameof(Enabled)), true);
Verbose = EditorPrefs.GetBool(GetPrefsFullName(nameof(Verbose)), true);
Verbose = EditorPrefs.GetBool(GetPrefsFullName(nameof(Verbose)), false);
Debug = EditorPrefs.GetBool(GetPrefsFullName(nameof(Debug)), false);
}

Expand Down
2 changes: 1 addition & 1 deletion UnityStreamDeck/UnityStreamDeck.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<PackageLicenseFile>LICENSE</PackageLicenseFile>
<PackageProjectUrl>https://github.com/nicollasricas/unity-streamdeck</PackageProjectUrl>
<RepositoryUrl>https://github.com/nicollasricas/unity-streamdeck</RepositoryUrl>
<Version>1.1.1</Version>
<Version>1.1.3</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="WebSocketSharp-netstandard" Version="1.0.1" />
Expand Down

0 comments on commit a787c2b

Please sign in to comment.