public bool CopyFrom(Transform root, AniFx aniFx) { if (aniFx == null) { return(true); } //复制预制体 prefab = aniFx.prefab; prefabFire = aniFx.prefabFire; prefabIce = aniFx.prefabIce; prefabThunder = aniFx.prefabThunder; prefabDark = aniFx.prefabDark; //复制骨骼 if (aniFx.bone != null && aniFx.type == enCreateType.bone) { string path = ""; bone = FindBone(root, aniFx.bone, ref path); if (bone == null) { return(false); } } else { bone = null; } //复制值类型的属性 Util.Copy(aniFx, this, BindingFlags.Public | BindingFlags.Instance); return(true); }
bool DrawFx(AniFx fx, AniFxGroup g, AniFxMgr aniFxMgr, Animation ani, string[] aniNames) { using (new AutoEditorIndentLevel(2)) { using (new AutoBeginHorizontal()) { fx.IsDrawGizmos = EditorGUILayout.Foldout(fx.IsDrawGizmos, fx.prefab == null ? "空" : fx.prefab.name); if (GUILayout.Button("删除", GUILayout.Width(45))) { return(true); } } if (fx.IsDrawGizmos) { using (new AutoEditorIndentLevel()) { fx.canHide = EditorGUILayout.Toggle("可以隐藏", fx.canHide); fx.prefab = (GameObject)EditorGUILayout.ObjectField("特效", fx.prefab, typeof(GameObject), false); fx.prefabFire = (GameObject)EditorGUILayout.ObjectField("特效(火)", fx.prefabFire, typeof(GameObject), false); fx.prefabIce = (GameObject)EditorGUILayout.ObjectField("特效(冰)", fx.prefabIce, typeof(GameObject), false); fx.prefabThunder = (GameObject)EditorGUILayout.ObjectField("特效(雷)", fx.prefabThunder, typeof(GameObject), false); fx.prefabDark = (GameObject)EditorGUILayout.ObjectField("特效(冥)", fx.prefabDark, typeof(GameObject), false); fx.type = (AniFx.enCreateType)EditorGUILayout.Popup("类型", (int)fx.type, AniFx.TypeName); if (fx.type == AniFx.enCreateType.bone) { fx.bone = (Transform)EditorGUILayout.ObjectField("骨骼", fx.bone, typeof(Transform)); fx.follow = EditorGUILayout.Toggle("跟随", fx.follow); fx.offset = EditorGUILayout.Vector3Field("位移", fx.offset); fx.euler = EditorGUILayout.Vector3Field("角度", fx.euler); } fx.destroyIfAniEnd = EditorGUILayout.Toggle("动作结束销毁", fx.destroyIfAniEnd); fx.beginFrame = EditorGUILayout.IntField("开始帧", fx.beginFrame); if (!fx.destroyIfAniEnd) { fx.endFrame = EditorGUILayout.IntField("结束帧数", fx.endFrame); } else if (fx.endFrame != -1) { fx.endFrame = -1; } fx.loopCreate = EditorGUILayout.Toggle("循环创建多次", fx.loopCreate); } } } return(false); }
public void CopyFrom(Transform root, AniFxGroup g) { if (g == null) { return; } //复制值类型的属性 Util.Copy(g, this, BindingFlags.Public | BindingFlags.Instance); for (int i = 0; i < g.fxs.Count; ++i) { AniFx fx = new AniFx(); if (fx.CopyFrom(root, g.fxs[i])) { fxs.Add(fx); } } }
bool DrawGroup(AniFxGroup g, AniFxMgr aniFxMgr, Animation ani, string[] aniNames) { //绘制 bool isShow; bool isClick; int idxOld = Array.IndexOf(aniNames, g.name); if (idxOld == -1) { using (new AutoChangeColor(Color.red)) EditorUtil.DrawHeaderBtn(g.name + "(动作找不到)", "删除", out isShow, out isClick); } else { AnimationState st = ani[g.name]; int maxFrame = (int)(st.length / Util.One_Frame); EditorUtil.DrawHeaderBtn(string.Format("{0}(共{1}帧)", g.name, maxFrame), "删除", out isShow, out isClick); } List <AniFx> removes = new List <AniFx>(); if (isShow) { using (new AutoContent()){ foreach (AniFx fx in g.fxs) { if (DrawFx(fx, g, aniFxMgr, ani, aniNames)) { removes.Add(fx); } } //添加 if (GUILayout.Button("添加")) { AniFx fx = new AniFx(); fx.follow = true; fx.destroyIfAniEnd = true; fx.endFrame = -1; g.fxs.Add(fx); } #if ART_DEBUG if (Application.isPlaying && GUILayout.Button("播放")) { SimpleRole.AttackCxt atk = new SimpleRole.AttackCxt(); atk.aniName = g.name; aniFxMgr.transform.parent.GetComponent <SimpleRole>().GotoState(SimpleRole.enState.attack, atk); } #endif } } else { foreach (AniFx fx in g.fxs) { if (fx.IsDrawGizmos) { fx.IsDrawGizmos = false; } } } //删除 foreach (AniFx fx in removes) { g.fxs.Remove(fx); } return(isClick); }