Пример #1
0
        public static void RefreshAll()
        {
            var roots = SceneManager.GetActiveScene().GetRootGameObjects();

            foreach (var root in roots)
            {
                var dict = UnityExtension.FindAllSerializableInstancesInHierarchy <Component, UICache>(root);
                foreach (var pair in dict)
                {
                    var component = pair.Key;
                    if (!component)
                    {
                        continue;
                    }

                    var founds = pair.Value;
                    var order  = -1;
                    foreach (var cache in founds)
                    {
                        ++order;
                        if (null == cache)
                        {
                            continue;
                        }

                        if (cache.GameObject)
                        {
                            cache.Rebuild();
                        }
                        else
                        {
                            Debug.Log(string.Format("FOUND NULL GO CACHE:{0}, TYPE:{1}, ORDER:{2}",
                                                    component.name, cache.GetType().Name, order));

                            cache.Assign(component.gameObject);
                        }
                    }
                }
            }
        }