예제 #1
0
파일: UITemplate.cs 프로젝트: hafewa/MAJIKA
 void Reload()
 {
     foreach (var bind in Bindings)
     {
         bind.lastSource = UITemplateUtility.GetValueByPath(dataSource, bind.PathSource);
         gameObject.SetValueByPath(bind.PathTemplate, bind.DataConverter ? bind.DataConverter.ConvertObjectTo(bind.lastSource) : bind.lastSource);
         bind.lastRender = gameObject.GetValueByPath(bind.PathTemplate);
     }
 }
예제 #2
0
 void Reload()
 {
     if (DataSource == null)
     {
         return;
     }
     foreach (var bind in Bindings)
     {
         gameObject.SetValueByPath(bind.PathTemplate, UITemplateUtility.GetValueByPath(dataSource, bind.PathSource));
     }
 }
예제 #3
0
파일: UITemplate.cs 프로젝트: hafewa/MAJIKA
 // Update is called once per frame
 void Update()
 {
     if (!Application.isPlaying)
     {
         GetComponentsInChildren <UIBehaviour>().ForEach((ui) =>
         {
             if (!ui.GetComponent <UITemplate>())
             {
                 ui.gameObject.AddComponent <UITemplate>();
             }
         });
     }
     foreach (var bind in Bindings)
     {
         if (bind.BindingMode == BindingMode.Static)
         {
             return;
         }
         var source   = UITemplateUtility.GetValueByPath(dataSource, bind.PathSource);
         var rendered = gameObject.GetValueByPath(bind.PathTemplate);
         if (bind.BindingMode == BindingMode.OneWay)
         {
             if (bind.lastSource != source)
             {
                 gameObject.SetValueByPath(bind.PathTemplate, bind.DataConverter ? bind.DataConverter.ConvertObjectTo(source) : source);
                 bind.lastSource = source;
                 bind.lastRender = gameObject.GetValueByPath(bind.PathTemplate);
             }
         }
         else if (bind.BindingMode == BindingMode.TwoWay)
         {
             if (bind.lastSource != source)
             {
                 gameObject.SetValueByPath(bind.PathTemplate, bind.DataConverter ? bind.DataConverter.ConvertObjectTo(source) : source);
                 bind.lastSource = source;
                 bind.lastRender = gameObject.GetValueByPath(bind.PathTemplate);
             }
             else if (bind.lastRender != rendered)
             {
                 UITemplateUtility.SetValueByPath(ref dataSource, bind.PathSource, rendered);
                 bind.lastSource = UITemplateUtility.GetValueByPath(dataSource, bind.PathSource);
                 bind.lastRender = rendered;
             }
         }
     }
 }
예제 #4
0
 // Update is called once per frame
 void Update()
 {
     if (!Application.isPlaying)
     {
         GetComponentsInChildren <UIBehaviour>().ForEach((ui) =>
         {
             if (!ui.GetComponent <UITemplate>())
             {
                 ui.gameObject.AddComponent <UITemplate>();
             }
         });
     }
     foreach (var bind in Bindings)
     {
         if (bind.BindingMode == BindingMode.OneWay)
         {
             gameObject.SetValueByPath(bind.PathTemplate, UITemplateUtility.GetValueByPath(dataSource, bind.PathSource));
             //UITemplateUtility.SetValueByPath(gameObject, bind.PathTemplate, UITemplateUtility.GetValueByPath(dataSource, bind.PathSource));
         }
     }
 }