void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height)); EditorGUILayout.BeginHorizontal(); MyGUI.TextFieldWithTitle("动画资源路径:", EffectFile); if (MyGUI.Button("动画资源列表刷新")) { load(); saveskeletonAsstes(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); MyGUI.TextFieldWithTitle("动画资源列表json路径:", EffectFilejson); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginVertical(); for (int i = EffectFileList.Count - 1; i >= 0; i--) { EditorGUILayout.LabelField(EffectFileList[i]); } EditorGUILayout.EndVertical(); EditorGUILayout.EndVertical(); }
void DrawActionData(ref ActionData actionData) { GUIStyle boxStyle = new GUIStyle("box"); EditorGUILayout.BeginVertical(boxStyle, GUILayout.ExpandWidth(true)); actionData.type = (ActionType)MyGUI.EnumPopupWithTitle("type", actionData.type); actionData.chance = MyGUI.IntFieldWithTitle("概率", actionData.chance); switch (actionData.type) { case ActionType.AddAttr: AttrType attrType = (AttrType)actionData.int1; attrType = (AttrType)MyGUI.EnumPopupWithTitle("属性", attrType); actionData.int1 = (int)attrType; actionData.float1 = MyGUI.FloatFieldWithTitle("数值", actionData.float1); break; case ActionType.AddAnim: actionData.string1 = MyGUI.TextFieldWithTitle("动画名", actionData.string1); actionData.bool1 = MyGUI.ToggleWithTitle("是否循环", actionData.bool1); break; case ActionType.RemoveAnim: actionData.string1 = MyGUI.TextFieldWithTitle("动画名", actionData.string1); break; case ActionType.SetColor: actionData.float1 = MyGUI.FloatFieldWithTitle("红", actionData.float1); actionData.float2 = MyGUI.FloatFieldWithTitle("绿", actionData.float2); actionData.float3 = MyGUI.FloatFieldWithTitle("蓝", actionData.float3); break; case ActionType.CreateDamage: // AttrType asd = (AttrType)actionData.int1; actionData.vector3_1 = MyGUI.Vector3WithTitle("pos", actionData.vector3_1); actionData.vector3_2 = MyGUI.Vector3WithTitle("size", actionData.vector3_2); actionData.vector3_3 = MyGUI.Vector3WithTitle("force", actionData.vector3_3); HitType hittype = (HitType)actionData.int1; hittype = (HitType)MyGUI.EnumPopupWithTitle("Hit Type", hittype); actionData.int1 = (int)hittype; Direction direction = (Direction)actionData.int2; direction = (Direction)MyGUI.EnumPopupWithTitle("Direction", direction); actionData.int2 = (int)direction; break; } EditorGUILayout.EndVertical(); }
List <DropItem> DrawDropItemList(ref List <DropItem> dropItemList) { EditorGUILayout.BeginVertical(); if (MyGUI.Button("添加")) { dropItemList.Add(new DropItem()); } if (dropItemList != null && dropItemList.Count > 0) { GUIStyle boxStyle = new GUIStyle("box"); EditorGUILayout.BeginVertical(boxStyle, GUILayout.ExpandWidth(true)); for (int i = 0; dropItemList.Count > i; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.BeginVertical(); if (MyGUI.Button("删除", GUILayout.Width(50))) { dropItemList.RemoveAt(i); break; } if (MyGUI.Button("复制", GUILayout.Width(50))) { var dropItem = Tools.Json2Obj <DropItem>(Tools.Obj2Json(dropItemList[i], true)); dropItemList.Add(dropItem); } EditorGUILayout.EndVertical(); GUIStyle nextbox = new GUIStyle("box"); EditorGUILayout.BeginVertical(nextbox, GUILayout.ExpandWidth(true)); dropItemList[i].itemType = (ItemType)MyGUI.EnumPopupWithTitle("ItemType", dropItemList[i].itemType); dropItemList[i].itemId = MyGUI.TextFieldWithTitle("itemId", dropItemList[i].itemId); dropItemList[i].chance = MyGUI.FloatFieldWithTitle("机率", dropItemList[i].chance); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } EditorGUILayout.EndVertical(); } EditorGUILayout.EndVertical(); return(dropItemList); }
private void BaseSkillInput(SkillData currSkillData) { #region 基本 MyGUIExtend.Instance.Foldout("基本" + this.currSkillData.id + currSkillData.id, "基本", () => { currSkillData.name = MyGUI.TextFieldWithTitle("name", currSkillData.name); MonoScript component = (MonoScript)AssetDatabase.LoadAssetAtPath(currSkillData.componentPath, typeof(MonoScript)); component = (UnityEditor.MonoScript)EditorGUILayout.ObjectField(new GUIContent("脚本"), component, typeof(UnityEditor.MonoScript), true); if (component != null) { currSkillData.componentPath = AssetDatabase.GetAssetPath(component); currSkillData.componentTypeName = component.GetClass().Namespace + "." + component.GetClass().Name; } currSkillData.SurvivalTime = MyGUI.FloatFieldWithTitle("存活时间", currSkillData.SurvivalTime); // 朝向模式 add by TangJian 2019/4/20 13:24 currSkillData.SkillOrientationMode = (SkillOrientationMode)MyGUI.EnumPopupWithTitle("朝向模式", currSkillData.SkillOrientationMode); }); #endregion #region 渲染 MyGUIExtend.Instance.Foldout("渲染" + this.currSkillData.id + currSkillData.id, "渲染", () => { currSkillData.rendererType = (RendererType)MyGUI.EnumPopupWithTitle("rander类型:", currSkillData.rendererType); switch (currSkillData.rendererType) { case RendererType.SkeletonAnimator: { Spine.Unity.SkeletonDataAsset SkeletonDataAsset = (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath( currSkillData.SkeletonDataAssetPath, typeof(Spine.Unity.SkeletonDataAsset)); UnityEditor.Animations.AnimatorController animatorController = (UnityEditor.Animations.AnimatorController)AssetDatabase.LoadAssetAtPath( currSkillData.AnimControllerPath, typeof(UnityEditor.Animations.AnimatorController)); animatorController = (UnityEditor.Animations.AnimatorController)EditorGUILayout.ObjectField( new GUIContent("动画控制器"), animatorController, typeof(UnityEditor.Animations.AnimatorController), true); SkeletonDataAsset = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField( new GUIContent("Skeleton"), SkeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset), true); currSkillData.SkeletonDataAssetPath = AssetDatabase.GetAssetPath(SkeletonDataAsset); currSkillData.AnimControllerPath = AssetDatabase.GetAssetPath(animatorController); if (SkeletonDataAsset != null) { string[] skins = new string[SkeletonDataAsset.GetSkeletonData(false).Skins.Count]; int skinIndex = 0; for (int i = 0; i < skins.Length; i++) { string skinNameString = SkeletonDataAsset.GetSkeletonData(false).Skins .Items[i].Name; skins[i] = skinNameString; if (skinNameString == currSkillData.SkinName) { skinIndex = i; } } skinIndex = EditorGUILayout.Popup("Initial Skin(皮肤)", skinIndex, skins); currSkillData.SkinName = skins[skinIndex]; } } break; case RendererType.Sprite: { currSkillData.SpritePath = MyGUI.ObjectField <Sprite>("精灵: ", currSkillData.SpritePath); } break; case RendererType.Skeleton: Spine.Unity.SkeletonDataAsset skeletonDataAsset = AssetDatabase.LoadAssetAtPath <Spine.Unity.SkeletonDataAsset>(currSkillData.SkeletonPath); skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField("Skeleton", skeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset)); currSkillData.SkeletonPath = AssetDatabase.GetAssetPath(skeletonDataAsset); if (skeletonDataAsset != null) { if (skeletonDataAsset != null && skeletonDataAsset.GetSkeletonData(false) != null && skeletonDataAsset.GetSkeletonData(false).Animations != null) { string[] Animations = new string[skeletonDataAsset.GetSkeletonData(false).Animations.Count]; int skinIndex = 0; for (int i = 0; i < Animations.Length; i++) { string skinNameString = skeletonDataAsset.GetSkeletonData(false).Animations.Items[i].Name; Animations[i] = skinNameString; if (skinNameString == currSkillData.SkeletonClipName) { skinIndex = i; } } skinIndex = EditorGUILayout.Popup("Animation(动画片段)", skinIndex, Animations); currSkillData.SkeletonClipName = Animations[skinIndex]; } } break; case RendererType.Anim: currSkillData.AnimName = EditorGUILayout.TextField("AnimName:", currSkillData.AnimName); break; default: Debug.Log("UnKnown:" + currSkillData.rendererType); break; } currSkillData.shadow = MyGUI.ToggleWithTitle("阴影", currSkillData.shadow); if (currSkillData.shadow) { currSkillData.shadowScale = MyGUI.Vector3WithTitle("阴影scale", currSkillData.shadowScale); currSkillData.CutOffDistance = MyGUI.FloatFieldWithTitle("阴影CutOffDistance", currSkillData.CutOffDistance); currSkillData.MaxScaleMultpler = MyGUI.FloatFieldWithTitle("阴影MaxScaleMultpler", currSkillData.MaxScaleMultpler); } }); #endregion }
public void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); MyGUI.Layout(position, boxStyle, new int[, ] { { 0, 1, 1 }, { 2, 1, 1 }, { 2, 1, 1 }, //{ 1, 1, 1 }, }, (Rect pos) => { EditorGUILayout.BeginVertical(); EditorGUILayout.LabelField(TagTirggerListPath); EditorGUILayout.BeginHorizontal(); if (MyGUI.Button("保存")) { savetagTirgger(); } if (MyGUI.Button("读取")) { LoadtagTirgger(); } if (MyGUI.Button("增加Tag")) { if (tagname != "" && tagname != null) { AddTag(tagname); } tagname = ""; } if (MyGUI.Button("删除Tag")) { if (tagname != "" && tagname != null) { RemoveTag(tagname); } tagname = ""; } EditorGUILayout.EndHorizontal(); tagname = MyGUI.TextFieldWithTitle("tagName:", tagname); EditorGUILayout.EndVertical(); }, (Rect pos) => { //EditorGUILayout.BeginHorizontal(); //if (MyGUI.Button("保存")) //{ //} //if (MyGUI.Button("读取")) //{ //} //EditorGUILayout.EndHorizontal(); DoGUI("hhh", ref windowbool, ref scrollPos, getValue, setValue, pos.width, pos.height, pos.x, pos.y); }, (Rect pos) => { taglistdogui(ref taglistbool, "dsa", pos.width - 10, pos.height - 10); }, (Rect pos) => { //DoGUI("hhh", ref windowbool, ref scrollPos, getValue, setValue, pos.width, pos.height,pos.x,pos.y); } ); //EditorGUILayout.BeginHorizontal(); //taglistdogui(ref taglistbool, "dsa"); //DoGUI("hhh", ref windowbool, ref scrollPos, getValue, setValue, width, height); //EditorGUILayout.EndHorizontal(); }
public override void OnInspectorGUI() { otherPrefabPath = MyGUI.TextFieldWithTitle("otherPrefabPath", otherPrefabPath); if (GUILayout.Button("添加预制体")) { try { gameObjectManager.PrefabPathList.Clear(); // 添加角色预制体 add by TangJian 2017/11/17 17:10:46 List <string> prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(rolePrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("添加角色预制体", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 添加物品预制体 add by TangJian 2017/11/17 17:10:53 prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(itemPrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("添加物品预制体", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 添加技能预制体 add by TangJian 2017/11/17 17:10:59 prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(skillPrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("添加技能预制体", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 添加特效预制体 add by TangJian 2017/11/17 17:11:09 prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(effectPrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("添加特效预制体", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 场景组件预制体 add by TangJian 2017/11/17 17:18:10 prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(placementPrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("其他预制体", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 添加地形预制体 add by TangJian 2019/3/25 21:21 prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(terrainPrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("加其他预制体", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 其他预制体 add by TangJian 2017/11/17 17:18:10 prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(otherPrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("其他预制体", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 粒子 add by TangJian 2017/11/17 17:18:10 prefabs = Tools.GetFileListInFolder(Tools.AssetPathToSysPath(particlePrefabPath), ".prefab"); for (int i = 0; i < prefabs.Count; i++) { var prefabPath = Tools.SysPathToAssetPath(prefabs[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); EditorUtility.DisplayProgressBar("粒子", i + "/" + prefabs.Count, (float)i / prefabs.Count); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabName, prefabPath)); } // 遍历所有预制体, 保存引用 { List <string> fileNames = Tools.GetFilesInFolder(Application.dataPath, ".prefab"); for (int i = 0; i < fileNames.Count; i++) { string fileName = fileNames[i]; EditorUtility.DisplayProgressBar("遍历所有预制体, 保存引用", fileName, (float)i / fileNames.Count); var prefabPath = Tools.SysPathToAssetPath(fileNames[i]); var prefabName = Path.GetFileNameWithoutExtension(prefabPath); gameObjectManager.PrefabPathList.Add(new GameObjectManager.PrefabPath(prefabPath, prefabPath)); } } foreach (var prefab in gameObjectManager.PrefabPathList) { if (gameObjectManager.prefabPathDic.ContainsKey(prefab.key)) { Debug.Log("存在同名预制体: " + prefab.key); } else { gameObjectManager.prefabPathDic.Add(prefab.key, prefab.path); } } } catch (Exception e) { Debug.LogError(e); } finally { EditorUtility.ClearProgressBar(); } } base.DrawDefaultInspector(); }
void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action> { { "读取", LoadRole }, { "All", () => { currtagname = ""; showIndexList.Clear(); for (int ix = 0; ix < _placementConfigList.Count; ix++) { showIndexList.Add(ix); } } }, { "仅保存数据", saveData }, { "保存数据仅生成当前选中预制体", () => { saveData(); Createprefab(); } } }); EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height)); MyGUIExtend.Instance.Foldout("BoxEditor", "路径信息", () => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(_roleDataFile); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(_prefabPath); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); _scalefloat = MyGUI.FloatFieldWithTitle("图片整体缩放大小", _scalefloat); EditorGUILayout.EndHorizontal(); }); // 编辑区域 add by TangJian 2017/11/15 16:28:19 EditorGUILayout.BeginHorizontal(); //一级列表 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width((innerBoxWidth / 2) * (1f / 3f) - 5f), GUILayout.ExpandHeight(true)); onelistViewPos = EditorGUILayout.BeginScrollView(onelistViewPos); for (int e = taglist.Count - 1; e >= 0; e--) { var tag = taglist[e]; EditorGUILayout.BeginHorizontal(); int Index = MyGUIExtend.Instance.ListSingleButton("BoxTag", taglist[e], e, (() => { currtagname = tag; showIndexList.Clear(); //firstbool = true; foreach (var item in _placementConfigList) { if (item.tagstring == tag) { showIndexList.Add(_placementConfigList.IndexOf(item)); } } })); MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action> { { "删除", (() => { taglist.RemoveAt(Index); }) } }); EditorGUILayout.EndVertical(); } newtagname = EditorGUILayout.TextField(newtagname, GUILayout.Width((innerBoxWidth / 2) * (1f / 3f) - 15f)); if (MyGUI.Button("+")) { taglist.Add(newtagname); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // // 二级列表框 add by TangJian 2017/11/15 16:27:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width((innerBoxWidth / 2) * (2f / 3f)), GUILayout.ExpandHeight(true)); SearchContext = GUILayout.TextField(SearchContext); _listScrollViewPos = EditorGUILayout.BeginScrollView(_listScrollViewPos); if (!string.IsNullOrEmpty(SearchContext)) { for (int i = 0; i < _placementConfigList.Count; i++) { if (Regex.IsMatch(_placementConfigList[i].id.ToLower(), SearchContext)) { ListID(i); } } } else { for (int i = _placementConfigList.Count - 1; i >= 0; i--) { if (!showIndexList.Contains(i)) { continue; } EditorGUILayout.BeginHorizontal(); ListID(i); EditorGUILayout.EndHorizontal(); } } if (MyGUI.Button("+")) { _placementConfigList.Add(new tian.PlacementConfig()); _placementConfigList[_placementConfigList.Count - 1].tagstring = currtagname; showIndexList.Add(_placementConfigList.Count - 1); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // 编辑框 add by TangJian 2017/11/15 16:28:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); _editScrollViewPos = EditorGUILayout.BeginScrollView(_editScrollViewPos); if (_currPlacementConfig != null) { _currPlacementConfig.tagstring = MyGUI.TextFieldWithTitle("标签", _currPlacementConfig.tagstring); _currPlacementConfig.id = MyGUI.TextFieldWithTitle("ID", _currPlacementConfig.id); _currPlacementConfig.prefab = MyGUI.TextFieldWithTitle("prefab", _currPlacementConfig.prefab); _currPlacementConfig.AddRigidbody = MyGUI.ToggleWithTitle("是否应用重力", _currPlacementConfig.AddRigidbody); _currPlacementConfig.colliderlayer = (tian.ColliderLayer)MyGUI.EnumPopupWithTitle("碰撞layer", _currPlacementConfig.colliderlayer); _currPlacementConfig.colliderSizeType = (tian.ColliderSizeType)MyGUI.EnumPopupWithTitle("size半自动与手工填写", _currPlacementConfig.colliderSizeType); _currPlacementConfig.placementData.deathEffect = MyGUI.TextFieldWithTitle("死亡动画|摧毁动画|爆炸动画", _currPlacementConfig.placementData.deathEffect); if (_currPlacementConfig.colliderSizeType != tian.ColliderSizeType.TextureRect) { _currPlacementConfig.boundsPosition = MyGUI.Vector3WithTitle("碰撞体position", _currPlacementConfig.boundsPosition); _currPlacementConfig.size = MyGUI.Vector3WithTitle("碰撞体size", _currPlacementConfig.size); } _currPlacementConfig.NoNavMeshObstacle = MyGUI.ToggleWithTitle("不需要NavMeshObstacle", _currPlacementConfig.NoNavMeshObstacle); _currPlacementConfig.NoSortRenderPos = MyGUI.ToggleWithTitle("不需要SortRenderPos", _currPlacementConfig.NoSortRenderPos); // Renderer朝向 add by TangJian 2018/12/18 15:57 _currPlacementConfig.RendererOrientation = (RendererOrientation)MyGUI.EnumPopupWithTitle("Renderer朝向", _currPlacementConfig.RendererOrientation); _currPlacementConfig.randerChoice = (tian.RanderChoice)MyGUI.EnumPopupWithTitle("Render选择", _currPlacementConfig.randerChoice); switch (_currPlacementConfig.randerChoice) { case tian.RanderChoice.Anim: Spine.Unity.SkeletonDataAsset skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(_currPlacementConfig.SkeletonDataAssetpath, typeof(Spine.Unity.SkeletonDataAsset)); UnityEditor.Animations.AnimatorController animatorController = (UnityEditor.Animations.AnimatorController)AssetDatabase.LoadAssetAtPath(_currPlacementConfig.AnimatorControllerpath, typeof(UnityEditor.Animations.AnimatorController)); animatorController = (UnityEditor.Animations.AnimatorController)EditorGUILayout.ObjectField(new GUIContent("动画控制器"), animatorController, typeof(UnityEditor.Animations.AnimatorController), true); skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField(new GUIContent("Skeleton"), skeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset), true); _currPlacementConfig.SkeletonDataAssetpath = AssetDatabase.GetAssetPath(skeletonDataAsset); _currPlacementConfig.AnimatorControllerpath = AssetDatabase.GetAssetPath(animatorController); _currPlacementConfig.ImagePath = ""; if (MyGUI.Button("打开纹理正面侧面编辑器")) { BoxTextureEditorWindow.Open(_currPlacementConfig); } break; case tian.RanderChoice.Image: _currPlacementConfig.sceneDecorationPosition = (SceneDecorationPosition)MyGUI.EnumPopupWithTitle("显示位置", _currPlacementConfig.sceneDecorationPosition); _usePathorImg = EditorGUILayout.ToggleLeft(new GUIContent("使用路径还是贴图"), _usePathorImg); Material material = AssetDatabase.LoadAssetAtPath <Material>(_currPlacementConfig.materialPath); material = (Material)EditorGUILayout.ObjectField("材质", material, typeof(Material), false); _currPlacementConfig.materialPath = AssetDatabase.GetAssetPath(material); if (_usePathorImg) { Texture2D img = (Texture2D)AssetDatabase.LoadAssetAtPath(_currPlacementConfig.ImagePath, typeof(Texture2D)); img = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("贴图"), img, typeof(Texture2D), _usePathorImg); _currPlacementConfig.ImagePath = AssetDatabase.GetAssetPath(img); EditorGUILayout.LabelField("图片路径:", _currPlacementConfig.ImagePath); } else { _currPlacementConfig.ImagePath = MyGUI.TextFieldWithTitle("图片路径:", _currPlacementConfig.ImagePath); Texture2D img = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("贴图"), AssetDatabase.LoadAssetAtPath(_currPlacementConfig.ImagePath, typeof(Texture2D)), typeof(Texture2D), _usePathorImg); } if (MyGUI.Button("打开纹理正面侧面编辑器")) { BoxTextureEditorWindow.Open(_currPlacementConfig); } _currPlacementConfig.scaleType = (tian.ScaleType)MyGUI.EnumPopupWithTitle("使用整体缩放大小还是单独缩放大小", _currPlacementConfig.scaleType); if (_currPlacementConfig.scaleType == tian.ScaleType.Alone) { _currPlacementConfig.AloneScale = MyGUI.FloatFieldWithTitle("单独缩放大小", _currPlacementConfig.AloneScale); } // currPlacementConfig.SkeletonDataAsset = null; // currPlacementConfig.AnimatorController = null; _currPlacementConfig.SkeletonDataAssetpath = ""; _currPlacementConfig.AnimatorControllerpath = ""; break; default: // currPlacementConfig.SkeletonDataAsset = null; _currPlacementConfig.ImagePath = ""; _currPlacementConfig.SkeletonDataAssetpath = ""; _currPlacementConfig.AnimatorControllerpath = ""; // currPlacementConfig.AnimatorController = null; break; } _currPlacementConfig.placementType = (tian.PlacementType)MyGUI.EnumPopupWithTitle("placementType", _currPlacementConfig.placementType); switch (_currPlacementConfig.placementType) { case tian.PlacementType.TreasureBox: DrawDropItemList(ref _currPlacementConfig.placementData.dropItemList); break; case tian.PlacementType.trap: _currPlacementConfig.atk = MyGUI.IntFieldWithTitle("Atk", _currPlacementConfig.atk); _currPlacementConfig.trapType = (tian.TrapType)MyGUI.EnumPopupWithTitle("陷阱类型:", _currPlacementConfig.trapType); switch (_currPlacementConfig.trapType) { case tian.TrapType.GroundStab: GroundStabStateType groundStabStateType = (GroundStabStateType)_currPlacementConfig.trapState; groundStabStateType = (GroundStabStateType)MyGUI.EnumPopupWithTitle("地刺类型", groundStabStateType); _currPlacementConfig.trapState = (int)groundStabStateType; string st1 = ""; string st2 = ""; switch (_currPlacementConfig.trapState) { case 0: st1 = "攻击延迟"; st2 = "关闭延迟"; break; case 1: st1 = "地刺地上停留时间"; st2 = "地刺地下停留时间"; _currPlacementConfig.float3 = MyGUI.FloatFieldWithTitle("首次停留时间", _currPlacementConfig.float3); break; } _currPlacementConfig.float1 = MyGUI.FloatFieldWithTitle(st1, _currPlacementConfig.float1); _currPlacementConfig.float2 = MyGUI.FloatFieldWithTitle(st2, _currPlacementConfig.float2); break; } break; case tian.PlacementType.bucket: _currPlacementConfig.placementData.hporCount = (tian.HporCount)MyGUI.EnumPopupWithTitle("打击数或hp", _currPlacementConfig.placementData.hporCount); switch (_currPlacementConfig.placementData.hporCount) { case tian.HporCount.Hp: _currPlacementConfig.placementData.atkhp = MyGUI.FloatFieldWithTitle("Hp", _currPlacementConfig.placementData.atkhp); break; case tian.HporCount.count: _currPlacementConfig.placementData.atkcount = MyGUI.IntFieldWithTitle("被打击次数", _currPlacementConfig.placementData.atkcount); break; default: break; } DrawDropItemList(ref _currPlacementConfig.placementData.dropItemList); break; case tian.PlacementType.Ladder: _currPlacementConfig.Laddertype = (laddertype)MyGUI.EnumPopupWithTitle("梯子在哪面", _currPlacementConfig.Laddertype); break; case PlacementType.FenceDoor: _currPlacementConfig.Laddertype = (laddertype)MyGUI.EnumPopupWithTitle("朝向", _currPlacementConfig.Laddertype); break; default: break; } // 材质类型 _currPlacementConfig.matType = (MatType)MyGUI.EnumPopupWithTitle("材质类型", _currPlacementConfig.matType); _currPlacementConfig.hitEffectType = (HitEffectType)MyGUI.EnumPopupWithTitle("打击效果类型", _currPlacementConfig.hitEffectType); //支持位移碰撞 _currPlacementConfig.placementShake = MyGUI.ToggleWithTitle("支持位移碰撞", _currPlacementConfig.placementShake); } else { if (currtagname != null) { EditorGUILayout.LabelField("当前选中标签:" + currtagname); newtagnae = MyGUI.TextFieldWithTitle("新标签名称:", newtagnae); if (MyGUI.Button("标签名称改动")) { if (taglist.Contains(currtagname)) { //taglist[taglist.IndexOf(currtagname)] = newtagnae; //currtagname = newtagnae; foreach (var children in _placementConfigList) { if (children.tagstring == currtagname) { children.tagstring = newtagnae; } } taglist[taglist.IndexOf(currtagname)] = newtagnae; currtagname = newtagnae; } newtagnae = ""; } } } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action> { { "读取", loadWeapon }, { "保存", saveWeapon }, { "制作当前预制体", CreatCurrentPrefab } }); EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height)); MyGUIExtend.Instance.Foldout("WeaponEditor", "路径信息", (() => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(weaponDataFile); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath); if (MyGUI.Button("载入表格")) { EditorTools.AnalyzeExcelToDic(excelPath, dic => { EquipType equipType = (EquipType)Convert.ToInt32(dic["EquipType"]); bool newWeaponData = true; switch (equipType) { case EquipType.Lswd: break; case EquipType.Shield: break; case EquipType.Swd: break; case EquipType.Sswd: break; case EquipType.Saxe: break; case EquipType.Blunt: break; case EquipType.Katana: break; case EquipType.Bow: break; case EquipType.Spear: break; default: newWeaponData = false; break; } if (newWeaponData) { WeaponData NewWeaponData = new WeaponData(); foreach (var item in dic) { switch (item.Key) { case "id": NewWeaponData.id = Convert.ToString(item.Value); break; case "IconName": NewWeaponData.icon = Convert.ToString(item.Value); break; case "name": NewWeaponData.name = Convert.ToString(item.Value); break; case "Lv": NewWeaponData.level = Convert.ToInt32(item.Value); break; case "desc": NewWeaponData.desc = Convert.ToString(item.Value); break; case "Hp": NewWeaponData.attrData.hpMax = Convert.ToSingle(item.Value); break; case "defence": NewWeaponData.attrData.def = Convert.ToSingle(item.Value); break; case "ATK": NewWeaponData.attrData.atk = Convert.ToSingle(item.Value); break; case "speed": NewWeaponData.attrData.atkSpeedScale = Convert.ToSingle(item.Value); break; case "Critical": NewWeaponData.attrData.criticalRate = Convert.ToSingle(item.Value); break; case "CriticalDamage": NewWeaponData.attrData.criticalDamage = Convert.ToSingle(item.Value); break; case "move": NewWeaponData.attrData.moveSpeedScale = Convert.ToSingle(item.Value); break; case "EquipType": NewWeaponData.equipType = equipType; break; } } int index = weaponDataList.FindIndex((data) => data.id == NewWeaponData.id); if (index >= 0) { string icon = weaponDataList[index].icon; weaponDataList.RemoveAt(index); NewWeaponData.icon = icon; } weaponDataList.Add(NewWeaponData); } }); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(prefabPath); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)AssetDatabase.LoadAssetAtPath(skeletonDataAssetPath, typeof(Spine.Unity.SkeletonDataAsset)); skeletonDataAsset = (Spine.Unity.SkeletonDataAsset)EditorGUILayout.ObjectField(new GUIContent("SkeletonDataAsstet"), skeletonDataAsset, typeof(Spine.Unity.SkeletonDataAsset), true); skeletonDataAssetPath = AssetDatabase.GetAssetPath(skeletonDataAsset); EditorGUILayout.EndHorizontal(); })); // 编辑区域 add by TangJian 2017/11/15 16:28:19 EditorGUILayout.BeginHorizontal(); // // 列表框 add by TangJian 2017/11/15 16:27:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos); for (int i = weaponDataList.Count - 1; i >= 0; i--) { var item = weaponDataList[i]; EditorGUILayout.BeginHorizontal(); int Index = MyGUIExtend.Instance.ListSingleButton("WeaponEditor", item.id, i, (() => { currWeaponData = item; })); MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action> { { "复制", (() => { var weaponData = Tools.Json2Obj <WeaponData>(Tools.Obj2Json(weaponDataList[Index], true)); weaponDataList.Add(weaponData); }) }, { "删除", (() => { weaponDataList.RemoveAt(Index); }) } }); EditorGUILayout.EndHorizontal(); } if (MyGUI.Button("+")) { weaponDataList.Add(new WeaponData()); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // 编辑框 add by TangJian 2017/11/15 16:28:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos); if (currWeaponData != null) { MyGUI.ItemDataField(currWeaponData, skeletonDataAssetPath); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
public override void OnInspectorGUI() { { EditorGUILayout.BeginHorizontal(); MyGUI.TextFieldWithTitle("碰撞区域名称", colliderName); if (MyGUI.Button("根据Renderer生成碰撞区域")) { foreach (var item in targets) { ColliderCreator itriggerDelegate = item as ColliderCreator; GameObject gameObject = itriggerDelegate.gameObject; Debug.Assert(gameObject != null); Bounds bounds = gameObject.GetRendererBounds(); bounds.center = new Vector3(bounds.center.x - gameObject.transform.position.x, bounds.center.y - gameObject.transform.position.y, bounds.center.z - gameObject.transform.position.z); // 创建交互区域 add by TangJian 2018/01/02 21:26:35 { float scale = 1f; GameObject interactObject = gameObject.GetChild(colliderName, true); interactObject.transform.localScale = new Vector3(1, 1, 1) * scale; interactObject.transform.localPosition = Vector3.zero; interactObject.transform.localEulerAngles = Vector3.zero; interactObject.layer = LayerMask.NameToLayer("Interaction"); BoxCollider boxCollider = interactObject.AddComponentUnique <BoxCollider>(); boxCollider.isTrigger = true; boxCollider.size = bounds.size; boxCollider.center = bounds.center; TriggerController triggerController = interactObject.AddComponentUnique <TriggerController>(); } } } if (MyGUI.Button("根据Collider生成碰撞区域")) { foreach (var item in targets) { ColliderCreator itriggerDelegate = item as ColliderCreator; GameObject gameObject = itriggerDelegate.gameObject; Debug.Assert(gameObject != null); Bounds bounds = gameObject.GetColliderBounds(); bounds.center = new Vector3(bounds.center.x - gameObject.transform.position.x, bounds.center.y - gameObject.transform.position.y, bounds.center.z - gameObject.transform.position.z); // 创建交互区域 add by TangJian 2018/01/02 21:26:35 { float scale = 1f; GameObject interactObject = gameObject.GetChild(colliderName, true); interactObject.transform.localScale = new Vector3(1, 1, 1) * scale; interactObject.transform.localPosition = Vector3.zero; interactObject.transform.localEulerAngles = Vector3.zero; interactObject.layer = LayerMask.NameToLayer("Interaction"); BoxCollider boxCollider = interactObject.AddComponentUnique <BoxCollider>(); boxCollider.isTrigger = true; boxCollider.size = bounds.size; boxCollider.center = bounds.center; TriggerController triggerController = interactObject.AddComponentUnique <TriggerController>(); } } } EditorGUILayout.EndHorizontal(); } DrawDefaultInspector(); }
public override void OnInspectorGUI() { if (Application.isPlaying) { animEffectId = MyGUI.TextFieldWithTitle("animEffectId", animEffectId); if (MyGUI.Button("测试特效")) { var playerObject = GameObject.Find("Player1"); AnimManager.Instance.PlayAnimEffect(animEffectId, playerObject.transform.position); } shakeEffectVisable = MyGUI.FoldoutWithTitle("Shake", shakeEffectVisable); if (shakeEffectVisable) { shakeXYEnum = (ShakeXYEnum)MyGUI.EnumPopupWithTitle("震动类型", shakeXYEnum); EditorGUILayout.BeginVertical(); duration = MyGUI.FloatFieldWithTitle("持续时间(duration)", duration); if (shakeXYEnum == ShakeXYEnum.ShakeV3) { strengthV3 = MyGUI.Vector3WithTitle("震动幅度(strength)Vector3", strengthV3); } else { strength = MyGUI.FloatFieldWithTitle("震动幅度(strength)", strength); } vibrato = MyGUI.IntFieldWithTitle("震动强度(vibrato)", vibrato); randomness = MyGUI.FloatFieldWithTitle("随机性震动(randomness)", randomness); snapping = MyGUI.ToggleWithTitle("snapping", snapping); fadeOut = MyGUI.ToggleWithTitle("fadeOut", fadeOut); EditorGUILayout.EndVertical(); if (MyGUI.Button("测试震动")) { switch (shakeXYEnum) { case ShakeXYEnum.FastShake: AnimManager.Instance.Shake(duration, strength, vibrato, randomness, snapping, fadeOut); break; case ShakeXYEnum.ShakeX: AnimManager.Instance.ShakeX(duration, strength, vibrato, randomness, snapping, fadeOut); break; case ShakeXYEnum.ShakeY: AnimManager.Instance.ShakeY(duration, strength, vibrato, randomness, snapping, fadeOut); break; case ShakeXYEnum.ShakeV3: AnimManager.Instance.ShakeV3(duration, strengthV3, vibrato, randomness, snapping, fadeOut); break; default: break; } } } CameraScaleVisable = MyGUI.FoldoutWithTitle("CameraScale", CameraScaleVisable); if (CameraScaleVisable) { CameraScale = MyGUI.FloatFieldWithTitle("Camerasize", CameraScale); if (MyGUI.Button("测试摄像机放大")) { AnimManager.Instance.CameraScaleUp(CameraScale); } } game = (GameObject)EditorGUILayout.ObjectField(new GUIContent("role"), game, typeof(GameObject), true); if (game != null) { longlong = MyGUI.FloatFieldWithTitle("long", longlong); heitht = MyGUI.FloatFieldWithTitle("height", heitht); t = MyGUI.FloatFieldWithTitle("", t); if (MyGUI.Button("测试伤害数值")) { Vector3 v3 = new Vector3(0, 3, 0) + game.transform.position; AnimManager.Instance.cebezierInterrupt("13", v3, 1f, false, longlong, heitht, t); } } } DrawDefaultInspector(); }
void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action> { { "读取", LoadData }, { "保存", SaveData }, { "制作预制体", CreatePrefabs } }); EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height)); MyGUIExtend.Instance.Foldout("DcorationEditor", "路径信息", (() => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(decorationDataFile); excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath); if (MyGUI.Button("载入Excel")) { EditorTools.AnalyzeExcelToDic(excelPath, dic => { EquipType equipType = (EquipType)Convert.ToInt32(dic["EquipType"]); switch (equipType) { case EquipType.Decoration: case EquipType.Glove: case EquipType.Shoe: case EquipType.Ring: DecorationData newDecorationData = new DecorationData(); foreach (var item in dic) { switch (item.Key) { case "id": newDecorationData.id = Convert.ToString(item.Value); break; case "IconName": newDecorationData.icon = Convert.ToString(item.Value); break; case "name": newDecorationData.name = Convert.ToString(item.Value); break; case "Lv": newDecorationData.level = Convert.ToInt32(item.Value); break; case "desc": newDecorationData.desc = Convert.ToString(item.Value); break; case "Hp": newDecorationData.attrData.hpMax = Convert.ToSingle(item.Value); break; case "defence": newDecorationData.attrData.def = Convert.ToSingle(item.Value); break; case "ATK": newDecorationData.attrData.atk = Convert.ToSingle(item.Value); break; case "speed": newDecorationData.attrData.atkSpeedScale = Convert.ToSingle(item.Value); break; case "Critical": newDecorationData.attrData.criticalRate = Convert.ToSingle(item.Value); break; case "CriticalDamage": newDecorationData.attrData.criticalDamage = Convert.ToSingle(item.Value); break; case "move": newDecorationData.attrData.moveSpeedScale = Convert.ToSingle(item.Value); break; case "EquipType": newDecorationData.equipType = equipType; break; } } int index = decorationDataList.FindIndex((data) => { return(data.id == newDecorationData.id); }); if (index >= 0) { decorationDataList.RemoveAt(index); } decorationDataList.Add(newDecorationData); break; } }); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(prefabPath); EditorGUILayout.EndHorizontal(); })); // 编辑区域 add by TangJian 2017/11/15 16:28:19 EditorGUILayout.BeginHorizontal(); // // 列表框 add by TangJian 2017/11/15 16:27:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos); for (int i = decorationDataList.Count - 1; i >= 0; i--) { var item = decorationDataList[i]; EditorGUILayout.BeginHorizontal(); int Index = MyGUIExtend.Instance.ListSingleButton("DocrationEditor", item.id, i, (() => { currDecorationData = item; })); MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action> { { "删除", (() => { decorationDataList.RemoveAt(Index); }) }, { "复制", () => { var decorationData = Tools.Json2Obj <DecorationData>(Tools.Obj2Json(decorationDataList[Index], true)); decorationDataList.Add(decorationData); } } }); EditorGUILayout.EndHorizontal(); } if (MyGUI.Button("+")) { decorationDataList.Add(new DecorationData()); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // 编辑框 add by TangJian 2017/11/15 16:28:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos); if (currDecorationData != null) { MyGUI.ItemDataField(currDecorationData); } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
private void OnGUI() { dropItemsDataAsset = (DropItemsDataAsset)EditorGUILayout.ObjectField("dropItemsDataAsset", dropItemsDataAsset, typeof(DropItemsDataAsset)); excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath); // text = GUILayout.TextArea(text, new GUIStyle(){}); if (MyGUI.Button("载入表格")) { dropItemsDataAsset.DropItemList.Clear(); EditorTools.AnalyzeExcel(excelPath, (List <KeyValuePair <string, object> > pairs) => { DropItemsDataAsset.DropItem dropItem = new DropItemsDataAsset.DropItem(); foreach (var pair in pairs) { switch (pair.Key) { case "id": dropItem.Id = Convert.ToString(pair.Value); break; case "MonsterID": dropItem.RoleId = Convert.ToString(pair.Value); break; case "Name": dropItem.RoleName = Convert.ToString(pair.Value); break; case "Lv": string[] lvs = Convert.ToString(pair.Value).Split(';'); dropItem.LvFrom = Convert.ToInt32(lvs[0]); dropItem.LvTo = Convert.ToInt32(lvs[1]); break; case "DropOne": dropItem.DropOne = Convert.ToInt32(pair.Value); break; case "DropTwo": dropItem.DropTwo = Convert.ToInt32(pair.Value); break; case "DropThree": dropItem.DropThree = Convert.ToInt32(pair.Value); break; case "DropSoul": dropItem.DropSoul = Convert.ToInt32(pair.Value); break; } } dropItemsDataAsset.DropItemList.Add(dropItem); }); EditorUtility.SetDirty(dropItemsDataAsset); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (MyGUI.Button("测试")) { text = ""; int instanceLevelMin = 1; int instanceLevelMax = 99; var roleIds = DropItemsDataAsset.Instance.GetAllRoleId(); foreach (var roleId in roleIds) { for (int instanceLevel = instanceLevelMin; instanceLevel <= instanceLevelMax; instanceLevel++) { List <string> dropItemIdList = DropItemsDataAsset.Instance.GetDropItemIdList(instanceLevel, roleId); int soulCount = DropItemsDataAsset.Instance.GetDropSoulCount(instanceLevel, roleId); text += "id: " + roleId + ", " + "instanceLevel: " + instanceLevel + ", dropItems: "; EditorUtility.DisplayProgressBar("测试", "id: " + roleId + ", " + "instanceLevel: " + instanceLevel + ", dropItems: ", (float)instanceLevel / instanceLevelMax); if (dropItemIdList != null) { for (int i = 0; i < dropItemIdList.Count; i++) { var dropItemId = dropItemIdList[i]; if (i == dropItemIdList.Count - 1) { text += dropItemId; text += "\n"; } else { text += dropItemId; text += ", "; } } } // 掉落魂数目 add by TangJian 2019/3/13 12:55 if (soulCount > 0) { text += ", Soulx" + soulCount; } text += "\n"; } } EditorUtility.ClearProgressBar(); } if (MyGUI.Button("测试1")) { // List<string> itemList = ItemManager.Instance.GetItemIdListDescendingOrder(0, 1, 0); // foreach (var itemId in itemList) // { // text += itemId; // text += "\n"; // } List <string> itemList = DropItemsDataAsset.Instance.GetDropItemIdList(9, "Human"); foreach (var itemId in itemList) { text += itemId; text += "\n"; } } textScrollViewPos = GUILayout.BeginScrollView(textScrollViewPos); text = EditorGUILayout.TextArea(text); GUILayout.EndScrollView(); }
private void OnGUI() { roleUpgradeDataAsset = (RoleUpgradeDataAsset)EditorGUILayout.ObjectField("roleUpgradeDataAsset", roleUpgradeDataAsset, typeof(DropItemsDataAsset)); excelPath = MyGUI.TextFieldWithTitle("表格路径", excelPath); // text = GUILayout.TextArea(text, new GUIStyle(){}); if (MyGUI.Button("载入表格")) { roleUpgradeDataAsset.Clear(); EditorTools.AnalyzeExcel(excelPath, (List <KeyValuePair <string, object> > pairs) => { DropItemsDataAsset.DropItem dropItem = new DropItemsDataAsset.DropItem(); int lv = -1; int exp = -1; foreach (var pair in pairs) { switch (pair.Key) { case "lv": lv = Convert.ToInt32(pair.Value); break; case "exp": exp = Convert.ToInt32(pair.Value); break; } } Debug.Assert(lv >= 1 && exp >= 0); roleUpgradeDataAsset.AddItem(lv, exp); }); EditorUtility.SetDirty(roleUpgradeDataAsset); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); } if (MyGUI.Button("测试")) { outputText = ""; outputText += "通过经验获取等级:\n"; for (int exp = 0; exp <= RoleUpgradeDataAsset.Instance.GetLevelMaxExp() * 2; exp++) { int level = RoleUpgradeDataAsset.Instance.GetLevel(exp); outputText += "exp: " + exp + " -> level: " + level + "\n"; } for (int i = 0; i < 10; i++) { outputText += "\n"; } outputText += "通过等级获取经验:\n"; for (int level = 1; level <= RoleUpgradeDataAsset.Instance.GetLevelMax(); level++) { int exp = RoleUpgradeDataAsset.Instance.GetExp(level); outputText += "level: " + level + " -> exp: " + exp + "\n"; } } outputTextScrollViewPos = EditorGUILayout.BeginScrollView(outputTextScrollViewPos, GUILayout.ExpandWidth(true)); outputText = EditorGUILayout.TextArea(outputText); EditorGUILayout.EndScrollView(); }
void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height)); // 设置路径, 以及存取数据 add by TangJian 2017/11/15 16:22:45 EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(SceneDecorationFile); if (MyGUI.Button("读取")) { loadSceneDecoration(); } if (MyGUI.Button("保存")) { saveSceneDecoration(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(prefabPath); if (MyGUI.Button("制作预制体")) { saveSceneDecoration(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); imgsclae = MyGUI.FloatFieldWithTitle("图片整体缩放大小", imgsclae); EditorGUILayout.EndHorizontal(); // 编辑区域 add by TangJian 2017/11/15 16:28:19 EditorGUILayout.BeginHorizontal(); // // 列表框 add by TangJian 2017/11/15 16:27:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos); for (int i = SceneDecorationList.Count - 1; i >= 0; i--) { var item = SceneDecorationList[i]; EditorGUILayout.BeginHorizontal(); if (MyGUI.Button("删除", GUILayout.Width(50))) { SceneDecorationList.RemoveAt(i); } if (MyGUI.Button(item.id)) { currSceneDecoration = item; } if (MyGUI.Button("复制", GUILayout.Width(50))) { var consumableData = Tools.Json2Obj <SceneDecorationEditorwindowData>(Tools.Obj2Json(item, true)); SceneDecorationList.Add(consumableData); } EditorGUILayout.EndHorizontal(); } if (MyGUI.Button("+")) { SceneDecorationList.Add(new SceneDecorationEditorwindowData()); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // 编辑框 add by TangJian 2017/11/15 16:28:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos); if (currSceneDecoration != null) { currSceneDecoration.id = MyGUI.TextFieldWithTitle("ID", currSceneDecoration.id); currSceneDecoration.sceneDecorationPosition = (SceneDecorationPosition)MyGUI.EnumPopupWithTitle("显示位置", currSceneDecoration.sceneDecorationPosition); UsePathorImg = EditorGUILayout.ToggleLeft(new GUIContent("使用路径还是贴图"), UsePathorImg); if (UsePathorImg) { Texture2D img = (Texture2D)AssetDatabase.LoadAssetAtPath(currSceneDecoration.texturePath, typeof(Texture2D)); img = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("贴图"), img, typeof(Texture2D), UsePathorImg); currSceneDecoration.texturePath = AssetDatabase.GetAssetPath(img); EditorGUILayout.LabelField("图片路径:", currSceneDecoration.texturePath); } else { currSceneDecoration.texturePath = MyGUI.TextFieldWithTitle("图片路径:", currSceneDecoration.texturePath); Texture2D img = (Texture2D)EditorGUILayout.ObjectField(new GUIContent("贴图"), AssetDatabase.LoadAssetAtPath(currSceneDecoration.texturePath, typeof(Texture2D)), typeof(Texture2D), UsePathorImg); } currSceneDecoration.scaleType = (tian.ScaleType)MyGUI.EnumPopupWithTitle("使用整体缩放大小还是单独缩放大小", currSceneDecoration.scaleType); if (currSceneDecoration.scaleType == tian.ScaleType.Alone) { currSceneDecoration.AloneScale = MyGUI.FloatFieldWithTitle("单独缩放大小", currSceneDecoration.AloneScale); } } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
void OnGUI() { GUIStyle boxStyle = new GUIStyle("box"); var width = position.size.x - boxStyle.border.horizontal; var height = position.size.y - boxStyle.border.vertical; var innerBoxWidth = width - (boxStyle.padding.horizontal + boxStyle.border.horizontal); var innerBoxHeight = height - (boxStyle.padding.vertical + boxStyle.border.vertical); MyGUIExtend.Instance.ToolbarButton(new Dictionary <string, Action> { { "读取", (() => { loadBuff(); }) }, { "保存", (() => { saveBuff(); }) } }); EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(width), GUILayout.Height(height)); // 设置路径, 以及存取数据 add by TangJian 2017/11/15 16:22:45 EditorGUILayout.BeginHorizontal(); MyGUIExtend.Instance.Foldout("BuffEditor", "路径信息", (() => { EditorGUILayout.LabelField(buffDataFile); })); EditorGUILayout.EndHorizontal(); // EditorGUILayout.BeginHorizontal(); // EditorGUILayout.LabelField(prefabPath); // if (MyGUI.Button("制作预制体")) // { // saveBuff(); // } // EditorGUILayout.EndHorizontal(); // 编辑区域 add by TangJian 2017/11/15 16:28:19 EditorGUILayout.BeginHorizontal(); // // 列表框 add by TangJian 2017/11/15 16:27:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); listScrollViewPos = EditorGUILayout.BeginScrollView(listScrollViewPos); for (int i = buffDataList.Count - 1; i >= 0; i--) { var item = buffDataList[i]; EditorGUILayout.BeginHorizontal(); int Index = MyGUIExtend.Instance.ListSingleButton("BuffEditor", item.id, i, (() => { currBuffData = item; })); MyGUIExtend.Instance.Mouse_RightDrop(new Dictionary <string, Action> { { "删除", (() => { buffDataList.RemoveAt(Index); }) }, { "复制", (() => { var buffData = Tools.Json2Obj <BuffData>(Tools.Obj2Json(buffDataList[Index], true)); buffDataList.Add(buffData); }) } }); EditorGUILayout.EndHorizontal(); } if (MyGUI.Button("+")) { buffDataList.Add(new BuffData()); } EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); // 编辑框 add by TangJian 2017/11/15 16:28:46 EditorGUILayout.BeginVertical(boxStyle, GUILayout.Width(innerBoxWidth / 2), GUILayout.ExpandHeight(true)); editScrollViewPos = EditorGUILayout.BeginScrollView(editScrollViewPos); if (currBuffData != null) { currBuffData.id = MyGUI.TextFieldWithTitle("id", currBuffData.id); currBuffData.name = MyGUI.TextFieldWithTitle("name", currBuffData.name); currBuffData.duration = MyGUI.FloatFieldWithTitle("duration", currBuffData.duration); currBuffData.updateInterval = MyGUI.FloatFieldWithTitle("updateInterval", currBuffData.updateInterval); currBuffData.attrData = MyGUI.AttrDataField(currBuffData.attrData); // currAddBuffEventType = (BuffEventType)MyGUI.EnumPopupWithTitle("事件类型", currAddBuffEventType); if (MyGUI.Button("添加")) { currBuffData.buffEvents.Add(currAddBuffEventType, new List <ActionData>()); } if (MyGUI.Button("移除")) { if (currBuffData.buffEvents.ContainsKey(currAddBuffEventType)) { currBuffData.buffEvents.Remove(currAddBuffEventType); } } List <BuffEventType> needRemoveBuffEventList = new List <BuffEventType>(); foreach (var buffEvent in currBuffData.buffEvents) { List <ActionData> actionDataList = buffEvent.Value; DrawActionList(buffEvent.Key.ToString(), ref actionDataList); } foreach (var item in needRemoveBuffEventList) { currBuffData.buffEvents.Remove(item); } } GUILayout.Space(10); EditorGUILayout.EndScrollView(); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); }
//SkillListManagerDataAsset skillManagerDataAsset; void OnGUI() { MyGUI.Layout( position, boxStyle, Layout, (Rect position) => { EditorGUILayout.LabelField(skillDataFile); if (MyGUI.Button("读取")) { Load(); } if (MyGUI.Button("保存")) { Save(); } }, (Rect position) => { int removeIndex = -1; int copyIndex = -1; if (skillListDatas.Count > 0) { for (int i = 0; i < skillListDatas.Count; i++) { GUILayout.BeginHorizontal(); if (MyGUI.Button("复制", GUILayout.Width(20))) { copyIndex = i; } if (MyGUI.Button(skillListDatas[i].id)) { currskillListData = skillListDatas[i]; focusIndex = i; } if (MyGUI.Button("-", GUILayout.Width(20))) { removeIndex = i; } GUILayout.EndHorizontal(); } } if (removeIndex >= 0) { skillListDatas.RemoveAt(removeIndex); } if (copyIndex >= 0) { //SkillListData skill = skillListDatas[copyIndex]; skillListDatas.Add(Tools.DepthClone(skillListDatas[copyIndex])); } if (MyGUI.Button("+")) { skillListDatas.Add(new SkillListSaveData()); } }, (Rect position) => { if (currskillListData != null) { Scrollpos = EditorGUILayout.BeginScrollView(Scrollpos); currskillListData.id = MyGUI.TextFieldWithTitle("id:", currskillListData.id); currskillListData.roleSkillListFrameEventData.RoleSkillListType = (RoleSkillListType)MyGUI.EnumPopupWithTitle("类型:", currskillListData.roleSkillListFrameEventData.RoleSkillListType); currskillListData.roleSkillListFrameEventData = MyGUI.Skilldatalistfield(currskillListData.roleSkillListFrameEventData, currskillListData.roleSkillListFrameEventData.RoleSkillListType); EditorGUILayout.EndScrollView(); } }, (Rect position) => { if (Application.isPlaying) { testTimes = MyGUI.IntFieldWithTitle("测试次数", testTimes); testInterval = MyGUI.FloatFieldWithTitle("间隔时间", testInterval); //moveOrientation = MyGUI.Vector3WithTitle("移动方向", moveOrientation); //testPosition = MyGUI.Vector3WithTitle("位置", testPosition); testFlip = MyGUI.ToggleWithTitle("翻转", testFlip); if (MyGUI.Button("测试特效")) { EditorCoroutineSequenceRunner.RemoveCoroutine("SkillList"); EditorCoroutineSequenceRunner.AddCoroutineIfNot("SkillList", TestAnimEffect(currskillListData, testTimes, testInterval)); } } }); }