Skip to content

Commit

Permalink
Cache is now loadable without update and several code changes to impr…
Browse files Browse the repository at this point in the history
…ove speed and reduce created garbage
  • Loading branch information
pak762 committed Feb 16, 2023
1 parent 2e2bd7f commit 6aca95a
Show file tree
Hide file tree
Showing 42 changed files with 2,588 additions and 2,313 deletions.
3,427 changes: 1,739 additions & 1,688 deletions AssetRelationsViewer/Editor/AssetRelationsViewerWindow.cs

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions AssetRelationsViewer/Editor/AssetTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ public string GetSortingKey(string name)
return $"Asset {name}";
}

public VisualizationNodeData CreateNodeCachedData(string id)
public VisualizationNodeData CreateNodeCachedData(Node node)
{
return new AssetVisualizationNodeData(id, GetHandledType());
return new AssetVisualizationNodeData(node);
}

public void SelectInEditor(string id)
Expand Down Expand Up @@ -72,7 +72,7 @@ public void OnSelectAsset(string id, string type)
}

public void InitContext(NodeDependencyLookupContext nodeDependencyLookupContext,
AssetRelationsViewerWindow window, INodeHandler nodeHandler)
AssetRelationsViewerWindow window)
{
_viewerWindow = window;
Selection.selectionChanged += HandleSyncToExplorer;
Expand Down
10 changes: 3 additions & 7 deletions AssetRelationsViewer/Editor/FileTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ namespace Com.Innogames.Core.Frontend.AssetRelationsViewer
public class FileTypeHandler : ITypeHandler
{
private Object _selectedAsset;
private AssetRelationsViewerWindow _viewerWindow;
private FileNodeHandler _nodeHandler;

public string GetHandledType()
{
Expand All @@ -21,9 +19,9 @@ public string GetSortingKey(string name)
return $"File {name}";
}

public VisualizationNodeData CreateNodeCachedData(string id)
public VisualizationNodeData CreateNodeCachedData(Node node)
{
return new FileVisualizationNodeData(id, GetHandledType());
return new FileVisualizationNodeData(node);
}

public void SelectInEditor(string id)
Expand Down Expand Up @@ -55,10 +53,8 @@ public void OnSelectAsset(string id, string type)
}
}

public void InitContext(NodeDependencyLookupContext nodeDependencyLookupContext, AssetRelationsViewerWindow window, INodeHandler nodeHandler)
public void InitContext(NodeDependencyLookupContext nodeDependencyLookupContext, AssetRelationsViewerWindow window)
{
_viewerWindow = window;
_nodeHandler = nodeHandler as FileNodeHandler;
}

public bool HandlesCurrentNode()
Expand Down
4 changes: 2 additions & 2 deletions AssetRelationsViewer/Editor/ITypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ public interface ITypeHandler
{
string GetHandledType();
string GetSortingKey(string name);
VisualizationNodeData CreateNodeCachedData(string id);
VisualizationNodeData CreateNodeCachedData(Node node);
void SelectInEditor(string id);
void OnGui();
void OnSelectAsset(string id, string type);
void InitContext(NodeDependencyLookupContext nodeDependencyLookupContext, AssetRelationsViewerWindow viewerWindow, INodeHandler nodeHandler);
void InitContext(NodeDependencyLookupContext nodeDependencyLookupContext, AssetRelationsViewerWindow viewerWindow);
bool HandlesCurrentNode();
}
}
22 changes: 13 additions & 9 deletions AssetRelationsViewer/Editor/InSceneTypeHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public class InSceneTypeHandler : ITypeHandler
private PrefValueBool SyncPref = new PrefValueBool("InSceneTypeHandler_Sync", false);
private PrefValueBool AutoRefreshPref = new PrefValueBool("InSceneTypeHandler_AutoRefresh", true);
private AssetRelationsViewerWindow _viewerWindow;
private InSceneDependencyNodeHandler _nodeHandler;
private NodeDependencyLookupContext _context;

private HashSet<string> _nodes = new HashSet<string>();

Expand All @@ -37,10 +37,10 @@ public string GetHandledType()

public string GetSortingKey(string name)
{
return name;
return $"InScene {name}";
}

public VisualizationNodeData CreateNodeCachedData(string id)
public VisualizationNodeData CreateNodeCachedData(Node node)
{
return new InSceneVisualizationNodeData();
}
Expand Down Expand Up @@ -93,7 +93,8 @@ public void OnGui()

public void OnSelectAsset(string id, string type)
{
GameObject node = _nodeHandler.GetGameObjectById(id);
InSceneDependencyNodeHandler nodeHandler = _context.NodeHandlerLookup[GetHandledType()] as InSceneDependencyNodeHandler;
GameObject node = nodeHandler.GetGameObjectById(id);

if (type == InSceneNodeType.Name && node != null)
{
Expand All @@ -102,10 +103,10 @@ public void OnSelectAsset(string id, string type)
}
}

public void InitContext(NodeDependencyLookupContext context, AssetRelationsViewerWindow viewerWindow, INodeHandler nodeHandler)
public void InitContext(NodeDependencyLookupContext context, AssetRelationsViewerWindow viewerWindow)
{
_viewerWindow = viewerWindow;
_nodeHandler = nodeHandler as InSceneDependencyNodeHandler;
_context = context;

HashSet<string> nodes = new HashSet<string>();

Expand All @@ -122,7 +123,9 @@ public void InitContext(NodeDependencyLookupContext context, AssetRelationsViewe
}

_nodes = new HashSet<string>(nodes);
_nodeHandler.BuildHashToGameObjectMapping();

InSceneDependencyNodeHandler nodeHandler = _context.NodeHandlerLookup[GetHandledType()] as InSceneDependencyNodeHandler;
nodeHandler.BuildHashToGameObjectMapping();

Selection.selectionChanged += SelectionChanged;
}
Expand All @@ -146,7 +149,8 @@ private void SelectionChanged()

if (_nodes.Contains(hashCode))
{
_currentNode = _nodeHandler.GetGameObjectById(hashCode);
InSceneDependencyNodeHandler nodeHandler = _context.NodeHandlerLookup[GetHandledType()] as InSceneDependencyNodeHandler;
_currentNode = nodeHandler.GetGameObjectById(hashCode);

if (SyncPref.GetValue())
{
Expand Down Expand Up @@ -179,7 +183,7 @@ private void AutoRefreshSceneAfterChange()

if (_currentLoadedSceneKey != 0 && loadedScenesKey != _currentLoadedSceneKey)
{
_viewerWindow.RefreshContext(cacheType, resolverType, null);
_viewerWindow.RefreshContext(cacheType, resolverType, null, true);
}

_currentLoadedSceneKey = loadedScenesKey;
Expand Down
153 changes: 0 additions & 153 deletions AssetRelationsViewer/Editor/NodeDataCache.cs

This file was deleted.

3 changes: 0 additions & 3 deletions AssetRelationsViewer/Editor/NodeDataCache.cs.meta

This file was deleted.

49 changes: 0 additions & 49 deletions AssetRelationsViewer/Editor/NodeSizeThread.cs

This file was deleted.

3 changes: 0 additions & 3 deletions AssetRelationsViewer/Editor/NodeSizeThread.cs.meta

This file was deleted.

6 changes: 5 additions & 1 deletion AssetRelationsViewer/Editor/PrefValue.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ namespace Com.Innogames.Core.Frontend.AssetRelationsViewer
public abstract class PrefValue<T>
{
protected T DefaultValue;
protected T CachedValue;

protected string Key;
protected T Value;
Expand All @@ -32,11 +33,14 @@ public PrefValue(string key, T defaultValue, T minValue, T maxValue)

MinValue = minValue;
MaxValue = maxValue;

CachedValue = GetValue();
}

public void SetValue(T value)
{
Value = value;
CachedValue = value;
Save();
}

Expand All @@ -59,7 +63,7 @@ public void DirtyOnChange(T newValue, Action<T> onChange = null)

public static implicit operator T(PrefValue<T> pref)
{
return pref.GetValue();
return pref.CachedValue;
}
}

Expand Down
Loading

0 comments on commit 6aca95a

Please sign in to comment.