BTC fix by Reto Spoerri
This commit is contained in:
		
							parent
							
								
									6227bd7f64
								
							
						
					
					
						commit
						fa9e6096d3
					
				@ -61,7 +61,7 @@ public class BTC : MonoBehaviour {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public List<ComponentController> namedObjects = new List<ComponentController>();
 | 
			
		||||
    private Dictionary<string, ComponentController> namedLookup = new();
 | 
			
		||||
    private Dictionary<int, ComponentController> namedLookup = new();
 | 
			
		||||
 | 
			
		||||
    private void OnEnable()
 | 
			
		||||
    {
 | 
			
		||||
@ -95,13 +95,13 @@ public class BTC : MonoBehaviour {
 | 
			
		||||
        foreach (var ctrl in namedObjects)
 | 
			
		||||
        {
 | 
			
		||||
            if (!string.IsNullOrEmpty(ctrl.objectName))
 | 
			
		||||
                namedLookup[ctrl.objectName] = ctrl;
 | 
			
		||||
                namedLookup[ctrl.objectName.GetHashCode()] = ctrl;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public T GetNamedObject<T>(string objectName) where T : ComponentController
 | 
			
		||||
    {
 | 
			
		||||
        if (namedLookup.TryGetValue(objectName, out var obj))
 | 
			
		||||
        if (namedLookup.TryGetValue(objectName.GetHashCode(), out var obj))
 | 
			
		||||
            return obj as T;
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
@ -99,15 +99,31 @@ public class ComponentController : MonoBehaviour {
 | 
			
		||||
    public string roomId;
 | 
			
		||||
    public string uniqueId;
 | 
			
		||||
 | 
			
		||||
    // cache the name
 | 
			
		||||
    public string _name;
 | 
			
		||||
    public string objectName {
 | 
			
		||||
        get {
 | 
			
		||||
            if (string.IsNullOrEmpty(_name))
 | 
			
		||||
            {
 | 
			
		||||
                _name = name;
 | 
			
		||||
            }
 | 
			
		||||
            return name;
 | 
			
		||||
        }
 | 
			
		||||
        set {
 | 
			
		||||
            name = value;
 | 
			
		||||
            _name = value;
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int objectHash
 | 
			
		||||
    {
 | 
			
		||||
        get
 | 
			
		||||
        {
 | 
			
		||||
            return name.GetHashCode();
 | 
			
		||||
        }
 | 
			
		||||
        set { }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public virtual void Awake () {
 | 
			
		||||
        UpdateObject();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user