Example #1
0
        void MakePrefab()
        {
            if (!string.IsNullOrEmpty(config.generatingType))
            {
                GameObject prefabTemplate = FindAssetObject <GameObject> ("@UI_PREFAB_TEMPLATE", PREFAB_EXT);
                if (prefabTemplate != null)
                {
                    GameObject newPrefab     = Instantiate(prefabTemplate);
                    Type       generatedType = ReflectUtils.GetTypeByName(config.generatingType);
                    if (generatedType != null)
                    {
                        ViewModelBehaviour newVM = (ViewModelBehaviour)newPrefab.AddComponent(generatedType);
                        newPrefab.name = config.generatingType;
                        newPrefab.GetComponent <DataContext> ().viewModel = newVM;
                    }

                    string newPrefabPath = UIManDefine.ASSETS_FOLDER + (config.generatingTypeIsDialog ? config.dialogPrefabFolder : config.screenPrefabFolder);
                    EditorUtils.CreatePath(newPrefabPath);
                    PrefabUtility.CreatePrefab(newPrefabPath + "/" + config.generatingType + PREFAB_EXT, newPrefab);

                    DestroyImmediate(newPrefab);
                }

                config.generatingType = null;
            }
        }
Example #2
0
        ViewModelBehaviour GetVMFromPool()
        {
            ViewModelBehaviour vm = vmsPool.Dequeue();

            vm.gameObject.name = "showing";
            return(vm);
        }
Example #3
0
        public ViewModelBehaviour GetIndex(int index)
        {
            ViewModelBehaviour result = null;

            if (listVMs != null && listVMs.Count < index)
            {
                result = listVMs [index];
            }

            return(result);
        }
Example #4
0
 void HandleOnAdd(object obj)
 {
     if (vmsPool.Count > 0)
     {
         ViewModelBehaviour vm     = GetVMFromPool();
         IModule            module = GetModuleFromPool();
         listVMs.Add(vm);
         listModules.Add(module);
         module.DataInstance = obj;
     }
     RecalculatePosition(listVMs.Count);
 }
Example #5
0
 void HandleOnInsert(int index, object obj)
 {
     if (vmsPool.Count > 0)
     {
         ViewModelBehaviour vm     = GetVMFromPool();
         IModule            module = GetModuleFromPool();
         listVMs.Insert(index, vm);
         listModules.Insert(index, module);
         module.DataInstance = obj;
     }
     RecalculatePosition(index);
 }
Example #6
0
 void InitPool()
 {
     for (int i = 0; i < poolSize; i++)
     {
         GameObject         obj = Instantiate(contentPrefab, hidePosition, Quaternion.identity) as GameObject;
         ViewModelBehaviour vm  = obj.GetComponent <ViewModelBehaviour> ();
         vmsPool.Enqueue(vm);
         IModule module = (IModule)vm;
         modulesPool.Enqueue(module);
         vm.Recttransform.SetParent(contentRect);
         vm.Recttransform.localScale = Vector3.one;
     }
 }
Example #7
0
 public void Clear()
 {
     viewModel    = null;
     propertyName = null;
     propertyInfo = null;
 }
Example #8
0
 void ReleaseVM(ViewModelBehaviour vm)
 {
     vmsPool.Enqueue(vm);
     vm.Recttransform.localPosition = hidePosition;
     vm.gameObject.name             = "free";
 }