maint: added livewatch asset

This commit is contained in:
Chris
2025-08-31 18:14:07 -04:00
parent 7f5d95787b
commit ae2371a6fa
385 changed files with 150792 additions and 0 deletions

View File

@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using UnityEngine;
namespace Ingvar.LiveWatch
{
[Serializable]
public struct OverridenValue<T> : IEquatable<OverridenValue<T>> where T : IEquatable<T>
{
[SerializeField] private bool isSet;
[SerializeField] private T value;
public bool IsSet => isSet;
public T Value => value;
public OverridenValue(T initialValue)
{
isSet = true;
value = initialValue;
}
public void SetValue(T setValue)
{
isSet = true;
value = setValue;
}
public bool Equals(OverridenValue<T> other)
{
return isSet && other.isSet && value.Equals(other.value)
|| !isSet && !other.isSet;
}
public override bool Equals(object obj)
{
return obj is OverridenValue<T> other && Equals(other);
}
public override int GetHashCode()
{
return HashCode.Combine(isSet, value);
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: bbc5c46530a74212ba5698b86e986707
timeCreated: 1717141617
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/Utilities/OverridenValue.cs
uploadId: 770587

View File

@@ -0,0 +1,142 @@
using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Serialization;
namespace Ingvar.LiveWatch
{
[Serializable]
public class RepetitiveValueList<T> where T : IEquatable<T>
{
public int Count
{
get => _count;
set => _count = value;
}
public List<int> OriginalKeys => _originalKeys;
public List<T> OriginalValues => _originalValues;
[SerializeField] private int _count = 0;
[SerializeField] private List<int> _originalKeys = new(1);
[SerializeField] private List<T> _originalValues = new(1);
private object _lockObject = new ();
private int _previousIndexOfOriginalKey;
private List<int> _indicesToOriginalKeysMap = new(1);
public bool AnyAt(int index)
{
return index >= 0 && index < _count;
}
public bool IsOriginalAt(int index)
{
if (index == 0)
return true;
var originalValueIndex = GetOriginalValueIndex(index);
var previousOriginalValueIndex = GetOriginalValueIndex(index-1);
return previousOriginalValueIndex != originalValueIndex;
}
public int GetOriginalIndex(int index)
{
var indexOfOriginalValue = GetOriginalValueIndex(index);
return _originalKeys[indexOfOriginalValue];
}
public void Add(T value)
{
if (_count == 0 || !_originalValues[^1].Equals(value))
{
_originalKeys.Add(_count);
_originalValues.Add(value);
}
_count++;
}
public void Expand(int expandCount)
{
if (_count == 0)
return;
_count += expandCount;
}
public T this[int index]
{
get
{
var indexOfOriginalValue = GetOriginalValueIndex(index);
return _originalValues[indexOfOriginalValue];
}
set
{
var indexOfOriginalValue = GetOriginalValueIndex(index);
_originalValues[indexOfOriginalValue] = value;
}
}
public void Clear()
{
_count = 0;
_originalKeys.Clear();
_originalValues.Clear();
_previousIndexOfOriginalKey = 0;
_indicesToOriginalKeysMap.Clear();
}
public void UpdateIndicesMap(int desiredIndex)
{
var startIndex = _indicesToOriginalKeysMap.Count;
var finishIndex = Mathf.Min(_originalKeys[^1] - 1, desiredIndex);
var currentLastIndex = _indicesToOriginalKeysMap.Count - 1;
if (_count == 0 || currentLastIndex >= finishIndex)
return;
for (var index = startIndex; index <= finishIndex; index++)
{
if (index == 0)
{
_indicesToOriginalKeysMap.Add(0);
continue;
}
if (_previousIndexOfOriginalKey == _originalKeys.Count - 1)
{
_indicesToOriginalKeysMap.Add(_indicesToOriginalKeysMap[^1]);
continue;
}
var nextOriginalKey = _originalKeys[_previousIndexOfOriginalKey + 1];
if (index < nextOriginalKey)
{
_indicesToOriginalKeysMap.Add(_indicesToOriginalKeysMap[^1]);
}
else
{
_indicesToOriginalKeysMap.Add(_indicesToOriginalKeysMap[^1] + 1);
_previousIndexOfOriginalKey++;
}
}
}
private int GetOriginalValueIndex(int index)
{
if (index >= _originalKeys[^1])
return _originalValues.Count - 1;
lock (_lockObject)
{
UpdateIndicesMap(index);
}
return _indicesToOriginalKeysMap[index];
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: 813e6dd3a8a54599aaaf2439227b0cd6
timeCreated: 1712997159
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/Utilities/RepetitiveValueList.cs
uploadId: 770587

View File

@@ -0,0 +1,22 @@
using System.IO;
using UnityEngine;
namespace Ingvar.LiveWatch
{
public abstract class Singleton<T> where T : new()
{
public static T instance
{
get
{
if (_instance != null)
return _instance;
_instance = new T();
return _instance;
}
}
private static T _instance;
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: b717d3e4766a4bbc94186b355c68048c
timeCreated: 1644152748
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/Utilities/Singleton.cs
uploadId: 770587

View File

@@ -0,0 +1,71 @@
using System;
using System.Collections.Generic;
namespace Ingvar.LiveWatch
{
[Flags]
public enum WatchFilters
{
None = 0,
FoldedIfChilds = 1 << 0,
NoValues = 1 << 1,
NoChilds = 1 << 2,
}
public static class WatchVariableQueryExtensions
{
public static void GetAllChildRecursive(this WatchStorage storage, List<WatchVariable> variables, WatchFilters breakFilters, WatchFilters continueFilters, bool includeItself = true)
{
variables.Clear();
foreach (var variableName in storage.SortedNames)
{
FindAllChildsRecursive(storage.Items[variableName], 0, variables, breakFilters, continueFilters, includeItself);
}
}
private static void FindAllChildsRecursive(WatchVariable variable, int recursionDepth, List<WatchVariable> results, WatchFilters breakFilters, WatchFilters continueFilters, bool includeItself = true)
{
if (includeItself && !SkippedByQuery(variable, continueFilters))
{
results.Add(variable);
}
if (recursionDepth >= Watch.MaxRecursionDepth
|| SkippedByQuery(variable, breakFilters))
{
return;
}
foreach (var childVariableName in variable.Childs.SortedNames)
{
FindAllChildsRecursive(variable.Childs.Items[childVariableName], recursionDepth + 1, results, breakFilters, continueFilters);
}
}
private static bool SkippedByQuery(WatchVariable variable, WatchFilters filters)
{
if (filters == WatchFilters.None)
{
return false;
}
if (filters.HasFlag(WatchFilters.FoldedIfChilds) && variable.HasChilds && !variable.EditorMeta.IsExpanded)
{
return true;
}
if (filters.HasFlag(WatchFilters.NoValues) && !variable.HasValues)
{
return true;
}
if (filters.HasFlag(WatchFilters.NoChilds) && !variable.HasChilds)
{
return true;
}
return false;
}
}
}

View File

@@ -0,0 +1,10 @@
fileFormatVersion: 2
guid: ea5b0b3ca3e14eac9c939a1705ee09ef
timeCreated: 1657218960
AssetOrigin:
serializedVersion: 1
productId: 324001
packageName: LiveWatch Lite | Debug with full history of changes
packageVersion: 1.0.1
assetPath: Assets/LiveWatchLite/Scripts/Utilities/WatchVariableQueryExtensions.cs
uploadId: 770587