public void AddPreset(SectionInfo info, bool checkDuplicate = true) { if (info == null) { return; } info.name = info.name.Trim(); if (checkDuplicate) { int i = presets.Count - 1; for (; i >= 0; i--) { if (presets[i].name.Equals(info.name)) { presets[i] = info; CreatePreview(presetList.GetChild(i + 1).gameObject, info); return; } } } presets.Add(info); selectedPresetGO = Instantiate(presetPrefab); CVSPPresetItem item = selectedPresetGO.GetComponent <CVSPPresetItem>(); item.name.text = info.name; item.info.text = $"w:{info.width:F2}\r\nh:{info.height:F2}"; selectedPresetGO.transform.SetParent(presetList); selectedPresetGO.SetActive(true); CreatePreview(selectedPresetGO, info); }
/// <summary> /// double click /// </summary> /// <param name="eventData"></param> void IPointerClickHandler.OnPointerClick(PointerEventData eventData) { selected = this; float unscaledTime = Time.unscaledTime; if (unscaledTime - eventData.clickTime < 0.3f) { if (unscaledTime - lastClick < 0.3f) { CVSPPresetManager.Instance.OnPresetSelected(); } lastClick = unscaledTime; } }
public void OnDeletePreset() { var g = CVSPPresetItem.delete.transform.parent; if (g) { CVSPPresetItem item = g.GetComponent <CVSPPresetItem>(); string name = item.name.text; name = Directory + name + ".xml"; if (File.Exists(name)) { File.Delete(name); } g.transform.SetParent(null); item.OnMouseExit(); Destroy(g.gameObject); } }