public void UpdateLastRect() { SpecialEffectEditorUtility.GetLastRect(ref lastRect); }
public bool DrawTreeNode(TreeViewNode n) { float spacePixelsPerLevel = 10f; float offset = 10f; nodeContent = new GUIContent(); EditorGUILayout.BeginHorizontal(); GUILayout.Space(offset); foreach (var p in n.state.userParams) { if (p.param.GetType() == typeof(bool)) { EditorGUILayout.LabelField(p.desc, toggleLabelStyle, GUILayout.Width(toggleLabelStyle.CalcSize(new GUIContent(p.desc)).x)); bool newState = EditorGUILayout.Toggle((bool)p.param, toggleStyle, new GUILayoutOption[] { GUILayout.MaxWidth(20f) }); if (newState != (bool)p.param) { currCtrl.frameTriggerInfo.isValueChanged = true; currCtrl.frameTriggerInfo.isCtrlBehaveChange = true; currCtrl.lastValueChangeNodePath = n.GetPathString(); currCtrl.CurrValue = n; } p.param = newState; } } GUILayout.Space(offset + spacePixelsPerLevel * (float)n.Level()); if (n.IsLeaf()) { n.state.IsExpand = false; } bool newExpandState = false; nodeContent.text = n.name; if (n.image != null) { nodeContent.image = n.image; } if (n.tooptip != "") { nodeContent.tooltip = n.tooptip; } if (n.IsLeaf()) {//叶节点绘制直接使用标签 GUILayout.Space(14f); EditorGUILayout.LabelField(nodeContent, labelStyle, GUILayout.Width(labelStyle.CalcSize(nodeContent).x)); } else { newExpandState = EditorGUILayout.Foldout(n.state.IsExpand, nodeContent, foldOutStyle); } SpecialEffectEditorUtility.GetLastRect(ref n.lastLabelRect); //若节点展开状态有变化则重绘 if (newExpandState != n.state.IsExpand) { currCtrl.frameTriggerInfo.isCtrlBehaveChange = true; RequestRepaint(); } if (currCtrl.Enable) { n.state.IsExpand = newExpandState; } //被选中节点绘制选中方形 if (n.Equals(currCtrl.currSelectNode)) { GUI.Box(n.lastRect, GUIContent.none); if (n.lastRect.size == new Vector2(0, 0)) { RequestRepaint(); } } EditorGUILayout.EndHorizontal(); SpecialEffectEditorUtility.GetLastRect(ref n.lastRect); HandleMouseInput(n); //若当前节点没有展开则略过此节点子树渲染 if (!n.state.IsExpand) { return(false); } return(true); }
private void _MarkSpecialEffectDirty() { SpecialEffect currSpe = target as SpecialEffect; SpecialEffectEditorUtility.MarkSpecialEffectDirty(currSpe); }
public override void Visit(EditorControl c) { currCtrl = c as PlayCtrl; if ( (null == currCtrl) ) { return; } EditorGUI.BeginDisabledGroup(!currCtrl.Enable); EditorGUILayout.BeginHorizontal(); float newPlayTime = 0.0f; try { GUI.SetNextControlName(currCtrl.CtrlID); newPlayTime = EditorGUILayout.Slider(currCtrl.PlayTime, 0.0f, currCtrl.TotalTime, new GUILayoutOption[] { GUILayout.ExpandWidth(true), GUILayout.Height(20f), GUILayout.MinWidth(300f) }); }catch (Exception e) { e.GetType(); //Debug.Log(e.Message); } EditorGUI.EndDisabledGroup(); c.UpdateLastRect(); CheckInputEvent(c); //若鼠标在播放条发生点按事件,暂停播放 if (c.LastRect.Contains(CalcLocalPos(c, FrameInputInfo.GetInstance().currPos))) { if ( FrameInputInfo.GetInstance().leftButtonDown&& FrameInputInfo.GetInstance().leftBtnPress&& c.IsCurrentCtrlEnable() ) { currCtrl.Pause(); } } if (!currCtrl.IsPlaying) { if (Mathf.Abs(currCtrl.PlayTime - newPlayTime) > Mathf.Epsilon) { currCtrl.frameTriggerInfo.isValueChanged = true; } currCtrl.PlayTime = newPlayTime; currCtrl.IsForceUpdate = false; } EditorGUI.BeginDisabledGroup(!currCtrl.Enable); GUILayoutOption[] btnOptions = new GUILayoutOption[] { GUILayout.Width(40), GUILayout.Height(20) }; if (!currCtrl.IsPlaying) { if (GUILayout.Button("播放", btnOptions)) { currCtrl.Play(); currCtrl.frameTriggerInfo.isValueChanged = true; currCtrl.frameTriggerInfo.isPlay = true; } } else { if (GUILayout.Button("暂停", btnOptions)) { currCtrl.Pause(); currCtrl.frameTriggerInfo.isValueChanged = true; currCtrl.frameTriggerInfo.isPause = true; } } //if( GUILayout.Button("播放", btnOptions) ) //{ // currCtrl.Play(); // currCtrl.frameTriggerInfo.isValueChanged = true; // currCtrl.frameTriggerInfo.isPlay = true; //} //if( GUILayout.Button("暂停", btnOptions) ) //{ // currCtrl.Pause(); // currCtrl.frameTriggerInfo.isValueChanged = true; // currCtrl.frameTriggerInfo.isPause = true; //} if (GUILayout.Button("停止", btnOptions)) { currCtrl.Stop(); currCtrl.frameTriggerInfo.isValueChanged = true; currCtrl.frameTriggerInfo.isStop = true; } EditorGUILayout.LabelField("Loop", GUILayout.Width(30f)); currCtrl.IsLoop = EditorGUILayout.Toggle(currCtrl.IsLoop, GUILayout.Width(20f)); EditorGUI.EndDisabledGroup(); EditorGUILayout.EndHorizontal(); SpecialEffectEditorUtility.GetLastRect(ref totalRect); CheckInputEvent(c, totalRect); }
public void ShowSingleElem(SerializedObject e, int count) { string errorMsg = string.Empty; if (null == e) { return; } SpecialEffectElement speElem = e.targetObject as SpecialEffectElement; if ( (null == speElem) || (null == speElem.gameObject) ) { return; } EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(8f), GUILayout.MaxWidth(30f)); EditorGUILayout.LabelField(speElem.gameObject.name, elemLableWidth); EditorGUILayout.EndHorizontal(); if (!SpecialEffectEditorUtility.IsSPEElementLegal(speElem, out errorMsg)) { EditorGUILayout.LabelField("特效元素无效", elemLableWidth); return; } EditorGUILayout.LabelField("起始时间(秒)", elemLableWidth); if (SpecialEffectEditorConfig.editableSpeInspector) { EditorGUILayout.PropertyField(e.FindProperty("startTime"), noneTextLable, floatCtrlWidth); } else { EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(8f), GUILayout.MaxWidth(30f)); //EditorGUILayout.FloatField(e.FindProperty("startTime").floatValue, elemLableWidth); EditorGUILayout.LabelField(e.FindProperty("startTime").floatValue.ToString(), elemLableWidth); EditorGUILayout.EndHorizontal(); } EditorGUILayout.LabelField("循环", GUILayout.MaxWidth(30f)); if (SpecialEffectEditorConfig.editableSpeInspector) { EditorGUILayout.PropertyField(e.FindProperty("isLoop"), noneTextLable, toggleWidth); } else { e.FindProperty("isLoop").boolValue = EditorGUILayout.Toggle(e.FindProperty("isLoop").boolValue, toggleWidth); } if (!e.FindProperty("isLoop").boolValue) { EditorGUILayout.LabelField("播放时长(秒)", elemLableWidth); if (SpecialEffectEditorConfig.editableSpeInspector) { EditorGUILayout.PropertyField(e.FindProperty("playTime"), noneTextLable, floatCtrlWidth); } else { EditorGUILayout.BeginHorizontal("AS TextArea", GUILayout.MinHeight(8f), GUILayout.MaxWidth(30f)); EditorGUILayout.LabelField(e.FindProperty("playTime").floatValue.ToString(), elemLableWidth); EditorGUILayout.EndHorizontal(); } } }