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; } }
ViewModelBehaviour GetVMFromPool() { ViewModelBehaviour vm = vmsPool.Dequeue(); vm.gameObject.name = "showing"; return(vm); }
public ViewModelBehaviour GetIndex(int index) { ViewModelBehaviour result = null; if (listVMs != null && listVMs.Count < index) { result = listVMs [index]; } return(result); }
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); }
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); }
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; } }
public void Clear() { viewModel = null; propertyName = null; propertyInfo = null; }
void ReleaseVM(ViewModelBehaviour vm) { vmsPool.Enqueue(vm); vm.Recttransform.localPosition = hidePosition; vm.gameObject.name = "free"; }