protected override GameObject CreateEntry(List <ValueEntry> sortedEntries, int i) { ValueEntry entry = sortedEntries[i]; var entryName = entry.Label.Clone(); var hasParent = entry.ParentEntry != null; var go = Instantiate(hasParent ? _prefabChildValue : _prefabEmptyValue, _contentTransform.transform); go.GetComponentInChildren <Button>().onClick.AddListener(() => { RemoveEntry(entry); _mainTimeline.Redraw(); }); var input = go.GetComponentInChildren <InputField>(); if (input != null) { input.SetTextWithoutNotify(entry.Label); input.onEndEdit.AddListener((s) => Rename(entry, s)); } var type = (ParameterType)((int)entry.Type % ((int)ParameterType.POS + 1)); GameObject field = null; switch (type) { case ParameterType.NUM: field = NewNumField(entry, go); break; case ParameterType.STRING: field = NewStringField(entry, go); break; case ParameterType.POS: field = NewVec2Field(entry, go); break; default: break; } var rect = field.GetComponent <RectTransform>(); rect.anchorMin = new Vector2(.5f, rect.anchorMin.y); rect.anchorMax = new Vector2(.9f, rect.anchorMax.y); return(go); }
protected GameObject InstantiateRefrenceValuePicker(ParameterData parameter, ParameterType type) { List <ValueEntry> refrenceValues = new List <ValueEntry>(); refrenceValues.AddRange(_mainTimeLine.CustomRefrenceValues); if (!parameter.IsRefrenceOnlyValue) { refrenceValues.AddRange(_mainTimeLine.GetScriptedRefrenceValues(false)); } List <string> options = ( from val in refrenceValues where val.Type.Equality(type) && val.ParentEntry == null select val.Label).ToList(); var valuePicker = Instantiate(_timeLine.EntryHudScriptableObject.ValuePicker, transform); var dropDown = valuePicker.GetComponentInChildren <Dropdown>(); dropDown.SetValueWithoutNotify(-1); options.Insert(0, "[New Value]"); dropDown.AddOptions(options); if (parameter.RefrenceValue != null) { dropDown.SetValueWithoutNotify(options.IndexOf(parameter.RefrenceValue.Label ?? "")); } dropDown.onValueChanged.AddListener( (optionIndex) => { if (optionIndex == 0) { parameter.RefrenceValue = CreateNewValue(type); _mainTimeLine.Redraw(); } else { parameter.RefrenceValue = refrenceValues.FirstOrDefault((value) => value.Label == options[optionIndex]); } }); return(valuePicker); }
public void Rename(string name, string newName) { _tabs[_tabs.IndexOf(name)] = newName; RedrawTabbar(); _mainTimeLine.Redraw(); }