Пример #1
0
        internal virtual void SetupView(UIViewProps props, IView parent, object[] @params)
        {
            if (props == null)
            {
                throw new Exception("UIView: UIViewProps can not be null");
            }

            SetupParent((UIObject)parent);
            ApplyProps(props, parent);
            InitCompleted(true);

            if (_stencilId.HasValue && _stencilId.Value != 0)
            {
                // TODO при изменении padding изменение canvas
                var meshRenderer = GameObject.AddComponent <MeshRenderer>();
                meshRenderer.sharedMaterial = UIStencilMaterials.GetOrCreate(_stencilId.Value).CanvasMaterial;
                meshRenderer.sharedMaterial.SetTexture("_MainTex", Texture2D.blackTexture);
                meshRenderer.sortingOrder = SortingOrder;

                SortingOrderChanged += sender =>
                {
                    meshRenderer.sortingOrder = SortingOrder;
                };

                UIStencilMaterials.CreateMesh(this);
            }

            mUI.ObjectCreated(this);
            CreateInterface(@params);
        }
Пример #2
0
        protected virtual void ApplyProps(UIViewProps props, IView parent)
        {
            base.ApplyProps(props);

            _stencilId = props.StencilId;
            SizeY      = props.SizeY ?? parent.SizeY;
            SizeX      = props.SizeX ?? parent.SizeX;
        }
Пример #3
0
        internal static UIView Create(Type viewType, UIViewProps props, IView parent, params object[] @params)
        {
            if (!IsViewType(viewType))
            {
                throw new Exception("The given viewType paramater is not UIView");
            }

            var view = (UIView) new GameObject(viewType.Name).AddComponent(viewType);

            view.SetupView(props, parent, @params);
            return(view);
        }
Пример #4
0
        public virtual UIView View(Type viewType, UIViewProps props, params object[] @params)
        {
            if (!IsViewType(viewType))
            {
                throw new Exception("The given viewType paramater is not UIView");
            }

            var view = (UIView) new GameObject(viewType.Name).AddComponent(viewType);

            view.SetupView(props, this, @params);
            return(view);
        }
Пример #5
0
 internal static T Create <T>(UIViewProps props, IView parent, params object[] @params) where T : UIView
 {
     return((T)Create(typeof(T), props, parent, @params));
 }
Пример #6
0
 public T View <T>(UIViewProps props, params object[] @params) where T : UIView
 {
     return((T)View(typeof(T), props, @params));
 }