Exemplo n.º 1
0
 public Transform GetTransformFromName(string objName)
 {
     if (DictObjName == null)
     {
         return(null);
     }
     return(DictObjName.TryGetValue(objName, out var gameObject) ? gameObject.transform : null);
 }
Exemplo n.º 2
0
 public GameObject GetObjectFromName(string objName)
 {
     if (DictObjName == null)
     {
         return(null);
     }
     DictObjName.TryGetValue(objName, out var result);
     return(result);
 }
Exemplo n.º 3
0
    public Transform GetTransformFromCandidates(string[] names)
    {
        if (DictObjName == null)
        {
            return(null);
        }
        var list = names.Where(name => DictObjName.ContainsKey(name)).Select(name => DictObjName[name].transform).ToArray();

        return(list.Length <= 0 ? null : list.First());
    }
Exemplo n.º 4
0
    private void FindAll(Transform trf)
    {
        if (!DictObjName.ContainsKey(trf.name))
        {
            DictObjName[trf.name] = trf.gameObject;
        }
        var tag = trf.tag;

        if (string.Empty != tag)
        {
            if (!DictTagName.TryGetValue(tag, out var list))
            {
                list             = new List <GameObject>();
                DictTagName[tag] = list;
            }

            list.Add(trf.gameObject);
        }

        for (var i = 0; i < trf.childCount; i++)
        {
            FindAll(trf.GetChild(i));
        }
    }