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>();
 | 
					    public List<ComponentController> namedObjects = new List<ComponentController>();
 | 
				
			||||||
    private Dictionary<string, ComponentController> namedLookup = new();
 | 
					    private Dictionary<int, 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] = ctrl;
 | 
					                namedLookup[ctrl.objectName.GetHashCode()] = ctrl;
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    public T GetNamedObject<T>(string objectName) where T : ComponentController
 | 
					    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 obj as T;
 | 
				
			||||||
        return null;
 | 
					        return null;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
@ -99,15 +99,31 @@ 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))
 | 
				
			||||||
 | 
					            {
 | 
				
			||||||
 | 
					                _name = name;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            return 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();
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user