static StackObject *AddToGameObject_3(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj) { ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain; StackObject *ptr_of_this_method; StackObject *__ret = ILIntepreter.Minus(__esp, 2); ptr_of_this_method = ILIntepreter.Minus(__esp, 1); Spine.Unity.SkeletonDataAsset @skeletonDataAsset = (Spine.Unity.SkeletonDataAsset) typeof(Spine.Unity.SkeletonDataAsset).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); ptr_of_this_method = ILIntepreter.Minus(__esp, 2); UnityEngine.GameObject @gameObject = (UnityEngine.GameObject) typeof(UnityEngine.GameObject).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack)); __intp.Free(ptr_of_this_method); var result_of_this_method = Spine.Unity.SkeletonAnimation.AddToGameObject(@gameObject, @skeletonDataAsset); object obj_result_of_this_method = result_of_this_method; if (obj_result_of_this_method is CrossBindingAdaptorType) { return(ILIntepreter.PushObject(__ret, __mStack, ((CrossBindingAdaptorType)obj_result_of_this_method).ILInstance)); } return(ILIntepreter.PushObject(__ret, __mStack, result_of_this_method)); }
public static SkeletonGraphic NewSkeletonGraphicGameObject(Spine.Unity.SkeletonDataAsset skeletonDataAsset, Transform parent) { SkeletonGraphic graphic = AddSkeletonGraphicComponent(new GameObject("New Spine GameObject"), skeletonDataAsset); if (parent != null) { graphic.transform.SetParent(parent, false); } return(graphic); }
public static T AddSpineComponent <T>(GameObject gameObject, Spine.Unity.SkeletonDataAsset skeletonDataAsset) where T : SkeletonRenderer { T local = gameObject.AddComponent <T>(); if (skeletonDataAsset != null) { local.skeletonDataAsset = skeletonDataAsset; local.Initialize(false); } return(local); }
public static SkeletonGraphic AddSkeletonGraphicComponent(GameObject gameObject, Spine.Unity.SkeletonDataAsset skeletonDataAsset) { SkeletonGraphic graphic = gameObject.AddComponent <SkeletonGraphic>(); if (skeletonDataAsset != null) { graphic.skeletonDataAsset = skeletonDataAsset; graphic.Initialize(false); } return(graphic); }
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(); }
public static T NewSpineGameObject <T>(Spine.Unity.SkeletonDataAsset skeletonDataAsset) where T : SkeletonRenderer => AddSpineComponent <T>(new GameObject("New Spine GameObject"), skeletonDataAsset);
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 static void LoadSpinAnimSkeleton(Spine.Unity.SkeletonAnimation anim, Qarth.ResLoader loader, string asset) { Spine.Unity.SkeletonDataAsset data = loader.LoadSync(asset) as Spine.Unity.SkeletonDataAsset; anim.skeletonDataAsset = data; anim.Initialize(true); }