当前位置: 首页 > news >正文

婚庆设计网站模板网站里的内容都是什么作用

婚庆设计网站模板,网站里的内容都是什么作用,网站百度排名提升,佛山网站建设计前言 在学习凉鞋老师的课程《QFramework系统设计#xff1a;通用背包系统》第四章时#xff0c;笔者使用了Odin插件#xff0c;对Item和ItemDatabase的SO文件进行了一些优化#xff0c;使物品页面更加紧凑、更易拓展。 核心逻辑和功能没有改动#xff0c;整体代码量减少…前言 在学习凉鞋老师的课程《QFramework系统设计通用背包系统》第四章时笔者使用了Odin插件对Item和ItemDatabase的SO文件进行了一些优化使物品页面更加紧凑、更易拓展。 核心逻辑和功能没有改动整体代码量减少了并且增加了一个复制ItemConfig的小功能。 需要注意 在ItemConfigGroup的列表中中删除ItemConfig时应该点红色的X按钮不要点最右侧的叉号不然关联的ItemConfig SO文件不会被同时删除QFramework带有的自定义属性功能可能会和Odin冲突建议只使用其中一种 为了和原教程区分下文将使用ItemConfig和ItemConfigGroup类来代替Item和ItemDatabase类。 修改前后对比 代码 IItem接口 using UnityEngine;namespace QFramework {public interface IItem{string GetKey { get; }string GetName { get; }string GetDescription { get; }Sprite GetIcon { get; }bool GetStackable { get; }bool GetHasMaxStackableCount { get; }int GetMaxStackableCount { get; }ItemLanguagePackage.LocalItem LocalItem { get; set; }bool GetBoolean(string propertyName);} }ItemConfig类 using Sirenix.OdinInspector; using UnityEditor; using UnityEngine;namespace QFramework {[CreateAssetMenu(menuName ItemKit/Create ItemConfig)]public class ItemConfig : ScriptableObject, IItem{public ItemConfigGroup ItemConfigGroup { get; set; }[HideLabel][PreviewField(48, ObjectFieldAlignment.Left)][HorizontalGroup(名称类型, 54), VerticalGroup(名称类型/left)]public Sprite Icon null;private void OnValidate(){this.name Key;}[VerticalGroup(名称类型/left)][Button(X), GUIColor(1, 0, 0)]private void RemoveThisConfig(){if (EditorUtility.DisplayDialog(删除物品, 确定要删除吗\n此操作不可恢复, 删除, 取消)){ItemConfigGroup.ItemConfigs.Remove(this);AssetDatabase.RemoveObjectFromAsset(this);AssetDatabase.SaveAssets();AssetDatabase.Refresh();}}[VerticalGroup(名称类型/left)][Button(Dup), GUIColor(yellow)]private void DuplicateThisConfig() // 增加复制/插入功能{if (ItemConfigGroup null){Debug.LogError(ItemConfigGroup is null!);return;}ItemConfigGroup.DuplicateItemConfig(ItemConfigGroup.ItemConfigs.IndexOf(this), this);}[VerticalGroup(名称类型/right), LabelWidth(42)][LabelText(名称)]public string Name string.Empty;[VerticalGroup(名称类型/right), LabelWidth(42)][LabelText(描述)][TextArea(minLines: 1, maxLines: 4)]public string Description string.Empty;[VerticalGroup(名称类型/right), LabelWidth(42)][LabelText(关键字)]public string Key string.Empty;[VerticalGroup(名称类型/right), LabelWidth(42)][LabelText(是武器)]public bool IsWeapon false;[HorizontalGroup(属性)][VerticalGroup(属性/stackable), LabelWidth(66)][LabelText(可堆叠)]public bool IsStackable true;[ShowIf(IsStackable)][VerticalGroup(属性/stackable), LabelWidth(66)][Indent][LabelText(有最大值)]public bool HasMaxStackableCount false;[ShowIf(IsStackable), EnableIf(HasMaxStackableCount)][DisplayIf(new string[] { IsStackable, HasMaxStackableCount }, new[] { false, false })][VerticalGroup(属性/stackable), LabelWidth(66)][Indent(2)][LabelText(最大值)]public int MaxStackableCount 99;public string GetName ItemKit.CurrentLanguage ItemKit.DefaultLanguage ? Name : LocalItem.Name;public string GetKey Key;public string GetDescription ItemKit.CurrentLanguage ItemKit.DefaultLanguage ? Description : LocalItem.Description;public Sprite GetIcon Icon;public bool GetStackable IsStackable;public bool GetHasMaxStackableCount HasMaxStackableCount;public int GetMaxStackableCount MaxStackableCount;public ItemLanguagePackage.LocalItem LocalItem { get; set; }public bool GetBoolean(string propertyName){if (propertyName IsWeapon){return IsWeapon;}return false;}} }ItemConfigGroup类 using Sirenix.OdinInspector; using System.Collections.Generic; using UnityEngine; using System.IO; using System; using UnityEditor;namespace QFramework {[CreateAssetMenu(menuName ItemKit/Create Item ConfigGroup)]public class ItemConfigGroup : ScriptableObject{public string NameSpace QFramework.Example;[Searchable][TableList(ShowIndexLabels true)]public ListItemConfig ItemConfigs new ListItemConfig();[Button(添加 ItemConfig, ButtonSizes.Large), GUIColor(yellow)]private void AddItemConfig(){// 创建一个新的 ItemConfig 实例ItemConfig itemConfig CreateInstanceItemConfig();itemConfig.ItemConfigGroup this;itemConfig.name nameof(ItemConfig);itemConfig.Name 新物品;itemConfig.Key item_new;// 将新创建的 itemConfig 添加到 ItemConfigGroup 的资源中AssetDatabase.AddObjectToAsset(itemConfig, this);// 在 ItemConfigs 列表中添加一个新的元素ItemConfigs.Add(itemConfig);// 保存所有更改到资源AssetDatabase.SaveAssets();// 刷新资源AssetDatabase.Refresh();}public void DuplicateItemConfig(int index, ItemConfig itemConfig){// 创建一个新的 ItemConfig 实例ItemConfig itemConfigSO CreateInstanceItemConfig();itemConfigSO.ItemConfigGroup this;itemConfigSO.name itemConfig.Key;itemConfigSO.Name string.Empty;itemConfigSO.Key item_new;itemConfigSO.IsWeapon itemConfig.IsWeapon;itemConfigSO.IsStackable itemConfig.IsStackable;itemConfigSO.HasMaxStackableCount itemConfig.HasMaxStackableCount;itemConfigSO.MaxStackableCount itemConfig.MaxStackableCount;// 将新创建的 itemConfig 添加到 ItemConfigGroup 的资源文件中AssetDatabase.AddObjectToAsset(itemConfigSO, this);// 在 ItemConfigs 列表中添加一个新的元素ItemConfigs.Insert(index 1, itemConfigSO);// 保存所有更改到资源AssetDatabase.SaveAssets();// 刷新资源AssetDatabase.Refresh();}[Button(生成 Items 代码, ButtonSizes.Large), GUIColor(green)]private void GenerateCode(){var itemDatabase this;// 获取当前 ItemDatabase 脚本的文件路径并确定生成代码的保存位置string filePath AssetDatabase.GetAssetPath(itemDatabase).GetFolderPath() /Items.cs;// 使用 QFramework 中的代码生成功能// 创建一个代码作用域树用于生成代码结构ICodeScope rootCode new RootCode()// 添加命名空间.Using(UnityEngine).Using(QFramework)// 空一行.EmptyLine()// 定义命名空间.Namespace(itemDatabase.NameSpace, ns {// 在命名空间中定义一个类ns.Class(Items, String.Empty, false, false, c {// 为每个 itemDB.ItemConfigs 生成一个静态字符串字段foreach (ItemConfig itemConfig in itemDatabase.ItemConfigs){c.Custom($public static string {itemConfig.Key} \{itemConfig.Key}\;);Debug.Log(itemConfig.Key);}});});// 创建或覆盖文件并准备写入生成的代码// 使用 using 语句自动管理 StreamWriter 的生命周期。// 当离开 using 代码块的作用域时fileWriter 的 Dispose 方法会被自动调用确保文件资源被正确关闭。using StreamWriter fileWriter File.CreateText(filePath);// 创建一个代码写入器将代码作用域树转换为字符串FileCodeWriter codeWriter new FileCodeWriter(fileWriter);// 生成代码并写入文件rootCode.Gen(codeWriter);// 保存所有未保存的资源更改AssetDatabase.SaveAssets();// 刷新 Unity 编辑器的资源数据库AssetDatabase.Refresh();}private void OnValidate(){foreach (ItemConfig itemConfig in ItemConfigs){if (itemConfig ! null){itemConfig.name itemConfig.Key;}elseItemConfigs.Remove(itemConfig);}}} }
http://www.pierceye.com/news/209414/

相关文章:

  • 网站开发的母的目的和意义.建设购物平台网站
  • 立方米网站建设做淘宝客网站用什么程序好
  • 怎样做网站挣钱建筑资料软件
  • 涿州建设局网站苏州市高新区建设局网站
  • 个人soho要怎么做企业网站成都包装设计公司
  • 网站开发 chrome浏览器崩溃ruhe用dw做网站
  • 全屏网站 图片优化个人网站cms系统
  • 做我女朋友程序网站邵东做网站
  • 建设网站如何挂到网上wordpress首页添加幻灯
  • 汕头正规网站建设模板总部城乡建设网站 资料员
  • vs 2017c 怎么建设网站网站建设的数字化和互联网化
  • 南昌网站设计公司海南营销网站建设
  • 购物网站素材个人搭建网站教程
  • 青岛网站建设哪里好模板建站服务公司
  • 青色网站欣赏wordpress中文购物
  • 建站培训全国住房与城乡建设部网站
  • 唐山网站建设方案策划沧州网站建设联系电话
  • 网页制作和网站开发实验报告logo设计品牌
  • 摄影后期教程网站百度指数1000搜索量有多少
  • wp网站建设模板什么是网站的原型
  • 园林绿化网站建设上海著名室内设计公司
  • 大连市住房与城乡建设部网站公司要制作网站
  • 郑州做网站七彩科技企业网站做的漂亮
  • 如何用ps做网站页面设计企业网站备案价格
  • 禅城网站建设价格青岛企业自助建站系统
  • 平阳住房和城乡建设厅网站建设银行龙卡信用卡在境外网站支付
  • 关于网站开发的论文软件开发合同模板免费
  • 军队房地产与建设工程法律实务在哪个网站可以购买深圳市盐田区住房建设局网站
  • 网站虚拟主机空间喊别人做的网站不肯给代码
  • 导游是什么商丘seo公司