Compare commits

..

No commits in common. "PerformanceV2" and "master" have entirely different histories.

2 changed files with 4 additions and 17 deletions

View File

@ -61,7 +61,7 @@ public class BTC : MonoBehaviour {
} }
public List<ComponentController> namedObjects = new List<ComponentController>(); public List<ComponentController> namedObjects = new List<ComponentController>();
private Dictionary<int, ComponentController> namedLookup = new(); private Dictionary<string, ComponentController> namedLookup = new();
private void OnEnable() private void OnEnable()
{ {
@ -95,13 +95,13 @@ public class BTC : MonoBehaviour {
foreach (var ctrl in namedObjects) foreach (var ctrl in namedObjects)
{ {
if (!string.IsNullOrEmpty(ctrl.objectName)) if (!string.IsNullOrEmpty(ctrl.objectName))
namedLookup[ctrl.objectName.GetHashCode()] = ctrl; namedLookup[ctrl.objectName] = ctrl;
} }
} }
public T GetNamedObject<T>(string objectName) where T : ComponentController public T GetNamedObject<T>(string objectName) where T : ComponentController
{ {
if (namedLookup.TryGetValue(objectName.GetHashCode(), out var obj)) if (namedLookup.TryGetValue(objectName, out var obj))
return obj as T; return obj as T;
return null; return null;
} }

View File

@ -99,28 +99,15 @@ public class ComponentController : MonoBehaviour {
public string roomId; public string roomId;
public string uniqueId; public string uniqueId;
// cache the name
public string _name;
public string objectName { public string objectName {
get { get {
if (string.IsNullOrEmpty(_name)) { return name;
_name = name;
}
return _name;
} }
set { set {
name = value; name = value;
_name = value;
} }
} }
public int objectHash {
get {
return name.GetHashCode();
}
set {}
}
public virtual void Awake () { public virtual void Awake () {
UpdateObject(); UpdateObject();
} }