Esempio n. 1
0
        protected bool Deactivate(T control, out bool destroyed)
        {
            destroyed = false;

            if (control == null)
            {
                return(false);
            }

            var configuration = DeviceController.GetConfiguration(control);
            var layer         = UILayerController.GetLayerView(configuration.appLayerId);
            var view          = layer.transform.Find(control.name);

            if (!view || !view.gameObject.activeSelf)
            {
                return(false);
            }

            if (control.ToDestroyOnDeactivation)
            {
                Object.Destroy(view.gameObject);
                destroyed = true;
            }
            else
            {
                view.gameObject.SetActive(false);
            }

            return(true);
        }
Esempio n. 2
0
        protected bool CheckControlIsActive(T control)
        {
            if (control == null)
            {
                return(false);
            }

            var configuration = DeviceController.GetConfiguration(control);
            var layer         = UILayerController.GetLayerView(configuration.appLayerId);
            var view          = layer.transform.Find(control.name);

            return(view != null && view.gameObject.activeSelf);
        }
Esempio n. 3
0
        protected GameObject GetInstance(T control, UIControlOptions options, out bool isNewInstance)
        {
            isNewInstance = false;
            if (control == null)
            {
                return(null);
            }

            var configuration = DeviceController.GetConfiguration(control);

            if (!CheckConfigInstalled(configuration))
            {
                InstallConfiguration(configuration);
            }

            var activate = (options & UIControlOptions.Activate) == UIControlOptions.Activate;
            var layer    = UILayerController.GetLayerView <Transform>(configuration.appLayerId);

            if (control.IsSingleInstance)
            {
                var instanceTransform = layer.Find(control.name);
                if (instanceTransform)
                {
                    if (activate)
                    {
                        instanceTransform.gameObject.SetActive(true);
                    }
                    return(instanceTransform.gameObject);
                }
            }

            var instantiate = (options & UIControlOptions.Instantiate) == UIControlOptions.Instantiate;

            if (!instantiate)
            {
                return(null);
            }

            isNewInstance = true;
            return(Instantiate(control, configuration, layer, activate));
        }
Esempio n. 4
0
        /*
         * Public.
         */

        public void Initialize(IEnumerable <T> controls)
        {
            foreach (var control in controls)
            {
                var configuration = DeviceController.GetConfiguration(control);
                if (CheckConfigInstalled(configuration))
                {
                    continue;
                }

                InstallConfiguration(configuration);

                if (!control.ToPreInstantiate)
                {
                    continue;
                }

                var layerView = UILayerController.GetLayerView <Transform>(configuration.appLayerId);
                Instantiate(control, configuration, layerView, false);
            }
        }
Esempio n. 5
0
 void OnDestroy()
 {
     instance = null;
 }