2024-07-19 Unity插件 Odin Inspector9 —— Validation Attributes

news2024/9/22 7:30:14

文章目录

  • 1 说明
  • 2 验证特性
    • 2.1 AssetsOnly / SceneObjectsOnly
    • 2.2 ChildGameObjectsOnly
    • 2.3 DisallowModificationsIn
    • 2.4 FilePath
    • 2.5 FolderPath
    • 2.6 MaxValue / MinValue
    • 2.7 MinMaxSlider
    • 2.8 PropertyRange
    • 2.9 Required
    • 2.10 RequiredIn
    • 2.11 RequiredListLength
    • 2.12 ValidateInput

1 说明

​ 本文介绍 Odin Inspector 插件中有关验证特性的使用方法。

2 验证特性

2.1 AssetsOnly / SceneObjectsOnly

使目标对象在 Inspector 窗口中只能关联资源 / 场景对象,限制拖拽的资源类型。

image-20240715004717713
// SceneAndAssetsOnlyExamplesComponent.cs

using Sirenix.OdinInspector;
using System.Collections.Generic;
using UnityEngine;

public class SceneAndAssetsOnlyExamplesComponent : MonoBehaviour
{
    [Title("Assets only")]
    [AssetsOnly]
    public List<GameObject> OnlyPrefabs;

    [AssetsOnly]
    public GameObject SomePrefab;

    [AssetsOnly]
    public Material MaterialAsset;

    [AssetsOnly]
    public MeshRenderer SomeMeshRendererOnPrefab;

    [Title("Scene Objects only")]
    [SceneObjectsOnly]
    public List<GameObject> OnlySceneObjects;

    [SceneObjectsOnly]
    public GameObject SomeSceneObject;

    [SceneObjectsOnly]
    public MeshRenderer SomeMeshRenderer;
}

2.2 ChildGameObjectsOnly

可用于 Components 和 GameObject,并在对象旁添加小按钮,点击按钮将显示其子物体中所有满足条件的对象。

  • IncludeSelf = true

    是否包含自身。

  • bool IncludeInactive

    是否包含未激活的子物体。

image-20240718021903335
// ChildGameObjectsOnlyAttributeExamplesComponent.cs

using Sirenix.OdinInspector;
using UnityEngine;

public class ChildGameObjectsOnlyAttributeExamplesComponent : MonoBehaviour
{
    [ChildGameObjectsOnly]
    public Transform ChildOrSelfTransform;

    [ChildGameObjectsOnly]
    public GameObject ChildGameObject;

    [ChildGameObjectsOnly(IncludeSelf = false)]
    public Light[] Lights;
}

2.3 DisallowModificationsIn

当该对象所在的脚本挂载在何种预制体上,其修饰的对象将被禁用 / 灰色显示。

  • PrefabKind prefabKind

    预制体的种类。

    1. None

      所有预制体,都不满足条件。

    2. InstanceInScene

      场景中的预制体实例。

    3. InstanceInPrefab

      嵌套在其他预制体中的预制件实例。

    4. Regular

      常规预制体。

    5. Variant

      预制体资产。

    6. NonPrefabInstance

      非预制体或场景中的游戏对象实例。

    7. PrefabInstance = InstanceInPrefab | InstanceInScene

      常规预制体的实例,以及场景中或嵌套在其他预制体中的预制体。

    8. PrefabAsset = Variant | Regular

      常规预制体和预制体资产。

    9. PrefabInstanceAndNonPrefabInstance = PrefabInstance | NonPrefabInstance

      预制体以及非预制实例。

    10. All = PrefabInstanceAndNonPrefabInstance | PrefabAsset

      所有预制体。

image-20240719003134858
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;

public class Test : MonoBehaviour
{
    [DisallowModificationsIn(PrefabKind.PrefabAsset)]
    public GameObject o;
}

2.4 FilePath

用于字符串,为文件路径提供接口。支持下拉选择文件路径和拖拽文件路径。

  • string ParentFolder

    父路径。可以相对于 Unity 项目,也可以是绝对路径。

  • string Extensions

    文件扩展名列表(以逗号分隔)。扩展名中的 “.” 可不写。

  • bool AbsolutePath

    是否为绝对路径。

  • bool RequireExistingPath

    true:若路径不存在,则显示警告提示。

  • bool UseBackslashes

    是否使用反斜杠(默认使用斜杠)。

image-20240718024034855
// FilePathExamplesComponent.cs
using Sirenix.OdinInspector;
using UnityEngine;

public class FilePathExamplesComponent : MonoBehaviour
{
    // By default, FolderPath provides a path relative to the Unity project.
    [FilePath]
    public string UnityProjectPath;
    
    // It is possible to provide custom parent path. Parent paths can be relative to the Unity project, or absolute.
    [FilePath(ParentFolder = "Assets/Plugins/Sirenix")]
    public string RelativeToParentPath;
    
    // Using parent path, FilePath can also provide a path relative to a resources folder.
    [FilePath(ParentFolder = "Assets/Resources")]
    public string ResourcePath;
    
    // Provide a comma seperated list of allowed extensions. Dots are optional.
    [FilePath(Extensions = "cs")]
    [BoxGroup("Conditions")]
    public string ScriptFiles;
    
    // By setting AbsolutePath to true, the FilePath will provide an absolute path instead.
    [FilePath(AbsolutePath = true)]
    [BoxGroup("Conditions")]
    public string AbsolutePath;
    
    // FilePath can also be configured to show an error, if the provided path is invalid.
    [FilePath(RequireExistingPath = true)]
    [BoxGroup("Conditions")]
    public string ExistingPath;
    
    // By default, FilePath will enforce the use of forward slashes. It can also be configured to use backslashes instead.
    [FilePath(UseBackslashes = true)]
    [BoxGroup("Conditions")]
    public string Backslashes;
    
    // FilePath also supports member references with the $ symbol.
    [FilePath(ParentFolder = "$DynamicParent", Extensions = "$DynamicExtensions")]
    [BoxGroup("Member referencing")]
    public string DynamicFilePath;
    
    [BoxGroup("Member referencing")]
    public string DynamicParent = "Assets/Plugins/Sirenix";
    
    [BoxGroup("Member referencing")]
    public string DynamicExtensions = "cs, unity, jpg";
    
    // FilePath also supports lists and arrays.
    [FilePath(ParentFolder = "Assets/Plugins/Sirenix/Demos/Odin Inspector")]
    [BoxGroup("Lists")]
    public string[] ListOfFiles;
}

2.5 FolderPath

用于字符串,为目录路径提供接口。支持下拉选择文件夹目录和拖拽文件夹目录。

  • string ParentFolder

    父路径。可以相对于 Unity 项目,也可以是绝对路径。

  • bool AbsolutePath

    是否为绝对路径。

  • bool RequireExistingPath

    true:若路径不存在,则显示警告提示。

  • bool UseBackslashes

    是否使用反斜杠(默认使用斜杠)。

image-20240718024439650
// FolderPathExamplesComponent.cs

using Sirenix.OdinInspector;
using UnityEngine;

public class FolderPathExamplesComponent : MonoBehaviour
{
    // By default, FolderPath provides a path relative to the Unity project.
    [FolderPath]
    public string UnityProjectPath;

    // It is possible to provide custom parent path. Parent paths can be relative to the Unity project, or absolute.
    [FolderPath(ParentFolder = "Assets/Plugins/Sirenix")]
    public string RelativeToParentPath;

    // Using parent path, FolderPath can also provide a path relative to a resources folder.
    [FolderPath(ParentFolder = "Assets/Resources")]
    public string ResourcePath;

    // By setting AbsolutePath to true, the FolderPath will provide an absolute path instead.
    [FolderPath(AbsolutePath = true)]
    [BoxGroup("Conditions")]
    public string AbsolutePath;

    // FolderPath can also be configured to show an error, if the provided path is invalid.
    [FolderPath(RequireExistingPath = true)]
    [BoxGroup("Conditions")]
    public string ExistingPath;

    // By default, FolderPath will enforce the use of forward slashes. It can also be configured to use backslashes instead.
    [FolderPath(UseBackslashes = true)]
    [BoxGroup("Conditions")]
    public string Backslashes;

    // FolderPath also supports member references and attribute expressions with the $ symbol.
    [FolderPath(ParentFolder = "$DynamicParent")]
    [BoxGroup("Member referencing")]
    public string DynamicFolderPath;

    [BoxGroup("Member referencing")]
    public string DynamicParent = "Assets/Plugins/Sirenix";

    // FolderPath also supports lists and arrays.
    [FolderPath(ParentFolder = "Assets/Plugins/Sirenix")]
    [BoxGroup("Lists")]
    public string[] ListOfFolders;
}

2.6 MaxValue / MinValue

在 Inspector 窗口中对象能够被设置的最小 / 大值。超过该范围则会有错误提示。

  • double maxValue/minValue

    最大 / 小值。

  • string Expression

    用于解析最大 / 小值的字符串。可以是字段、属性、方法名或表达式。

image-20240716045038267
// MinMaxValueValueExamplesComponent.cs

using Sirenix.OdinInspector;
using UnityEngine;

public class MinMaxValueValueExamplesComponent : MonoBehaviour
{
    // Ints
    [Title("Int")]
    [MinValue(0)]
    public int IntMinValue0;

    [MaxValue(0)]
    public int IntMaxValue0;

    // Floats
    [Title("Float")]
    [MinValue(0)]
    public float FloatMinValue0;

    [MaxValue(0)]
    public float FloatMaxValue0;

    // Vectors
    [Title("Vectors")]
    [MinValue(0)]
    public Vector3 Vector3MinValue0;

    [MaxValue(0)]
    public Vector3 Vector3MaxValue0;
}

2.7 MinMaxSlider

将 Vector2 向量表示为 [min, max] 区间,并在 Inspector 窗口中以滑动条方式显示。其中,x 为最小值,y 为最大值。

  • float minValue/maxValue

    最小 / 大值。

  • string minValueGetter/maxValueGetter

    获取最小 / 大值的方法名称。

  • string minMaxValueGetter

    获取最小、大值对的方法名称。

  • bool showFields = false

    是否显示对象名称。

image-20240716045759075
// MinMaxSliderExamplesComponent.cs

using Sirenix.OdinInspector;
using UnityEngine;

public class MinMaxSliderExamplesComponent : MonoBehaviour
{
    [MinMaxSlider(-10, 10)]
    public Vector2 MinMaxValueSlider = new Vector2(-7, -2);

    [MinMaxSlider(-10, 10, true)]
    public Vector2 WithFields = new Vector2(-3, 4);

    [InfoBox("You can also assign the min max values dynamically by referring to members.")]
    [MinMaxSlider("DynamicRange", true)]
    public Vector2 DynamicMinMax = new Vector2(25, 50);

    [MinMaxSlider("Min", 10f, true)]
    public Vector2 DynamicMin = new Vector2(2, 7);

    [InfoBox("You can also use attribute expressions with the @ symbol.")]
    [MinMaxSlider("@DynamicRange.x", "@DynamicRange.y * 10f", true)]
    public Vector2 Expressive = new Vector2(0, 450);

    public Vector2 DynamicRange = new Vector2(0, 50);

    public float Min { get { return this.DynamicRange.x; } }

    public float Max { get { return this.DynamicRange.y; } }
}

2.8 PropertyRange

创建滑块控件,将属性的值设置在指定范围之间。

  • double min/max

    最小 / 大值。

  • string minGetter/maxGetter

    获取最小、大值的方法名称。

image-20240716051249151
// PropertyRangeExampleComponent.cs

using Sirenix.OdinInspector;
using UnityEngine;

public class PropertyRangeExampleComponent : MonoBehaviour
{
    [Range(0, 10)]
    public int Field = 2;

    [InfoBox("Odin's PropertyRange attribute is similar to Unity's Range attribute, but also works on properties.")]
    [ShowInInspector, PropertyRange(0, 10)]
    public int Property { get; set; }

    [InfoBox("You can also reference member for either or both min and max values.")]
    [PropertyRange(0, "Max"), PropertyOrder(3)]
    public int Dynamic = 6;

    [PropertyOrder(4)]
    public int Max = 100;
}

2.9 Required

如果对象没有被关联,则显示错误信息。

  • string errorMessage

    显示信息。

  • InfoMessageType messageType

    信息类型。

image-20240715005824011
// RequiredExamplesComponent.cs
using Sirenix.OdinInspector;
using UnityEngine;

public class RequiredExamplesComponent : MonoBehaviour
{
    [Required]
    public GameObject MyGameObject;
    
    [Required("Custom error message.")]
    public Rigidbody MyRigidbody;
    
    [InfoBox("Use $ to indicate a member string as message.")]
    [Required("$DynamicMessage")]
    public GameObject GameObject;
    
    public string DynamicMessage = "Dynamic error message";
}

2.10 RequiredIn

当该对象所在的脚本挂载在何种预制体上,其修饰的对象必须被关联,否则显示错误信息。

  • string errorMessage

    显示信息。

  • PrefabKind prefabKind

    预制体的种类。

    1. None

      所有预制体,都不满足条件。

    2. InstanceInScene

      场景中的预制体实例。

    3. InstanceInPrefab

      嵌套在其他预制体中的预制件实例。

    4. Regular

      常规预制体。

    5. Variant

      预制体资产。

    6. NonPrefabInstance

      非预制体或场景中的游戏对象实例。

    7. PrefabInstance = InstanceInPrefab | InstanceInScene

      常规预制体的实例,以及场景中或嵌套在其他预制体中的预制体。

    8. PrefabAsset = Variant | Regular

      常规预制体和预制体资产。

    9. PrefabInstanceAndNonPrefabInstance = PrefabInstance | NonPrefabInstance

      预制体以及非预制实例。

    10. All = PrefabInstanceAndNonPrefabInstance | PrefabAsset

      所有预制体。

image-20240715232923256
using System.Collections;
using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;

public class Test : MonoBehaviour
{
    [RequiredIn(PrefabKind.PrefabAsset)]
    public GameObject o;
}

2.11 RequiredListLength

将 List 限制为包含指定数量的元素。

  • int minLength/maxLength

    最小 / 大长度。

  • string minLengthGetter/maxLengthGetter

    用于获取集合最小 / 大长度的 C# 表达式,例如“@this.otherList.Count”。

    如果设置了 MinLength,则当 MinLengthGetter 返回 null 时,MinLength 将作为回退。

  • string fixedLengthGetter

    用于获取集合长度的 C# 表达式。

  • PrefabKind PrefabKind

    长度限制应用于哪种预制体上。

image-20240719004053613
// RequiredListLengthExamplesComponent.cs

using System.Collections.Generic;
using Sirenix.OdinInspector;
using UnityEngine;

public class RequiredListLengthExamplesComponent : MonoBehaviour
{
    [RequiredListLength(10)]
    public int[] fixedLength;
    
    [RequiredListLength(1, null)]
    public int[] minLength;
    
    [RequiredListLength(null, 10, PrefabKind = PrefabKind.InstanceInScene)]
    public List<int> maxLength;
    
    [RequiredListLength(3, 10)]
    public List<int> minAndMaxLength;
    
    public int SomeNumber;
    
    [RequiredListLength("@this.SomeNumber")] 
    public List<GameObject> matchLengthOfOther;
    
    [RequiredListLength("@this.SomeNumber", null)]
    public int[] minLengthExpression;
    
    [RequiredListLength(null, "@this.SomeNumber")]
    public List<int> maxLengthExpression;
}

2.12 ValidateInput

允许检查 Inspector 窗口中拖拽关联值是否正确。

  • string condition

    判断是否正确的方法。

  • string defaultMessage

    显示信息。

  • InfoMessageType messageType

    信息类型。

image-20240715011220919
// ValidateInputExamplesComponent.cs

using Sirenix.OdinInspector;
using UnityEngine;

#if UNITY_EDITOR // Editor namespaces can only be used in the editor.
using Sirenix.OdinInspector.Editor.Examples;
#endif

public class ValidateInputExamplesComponent : MonoBehaviour
{
#if UNITY_EDITOR // MyScriptyScriptableObject is an example type and only exists in the editor
    [HideLabel]
    [Title("Default message", "You can just provide a default message that is always used")]
    [ValidateInput("MustBeNull", "This field should be null.")]
    public MyScriptyScriptableObject DefaultMessage;
#endif

    [Space(12), HideLabel]
    [Title("Dynamic message", "Or the validation method can dynamically provide a custom message")]
    [ValidateInput("HasMeshRendererDynamicMessage", "Prefab must have a MeshRenderer component")]
    public GameObject DynamicMessage;

    [Space(12), HideLabel]
    [Title("Dynamic message type", "The validation method can also control the type of the message")]
    [ValidateInput("HasMeshRendererDynamicMessageAndType", "Prefab must have a MeshRenderer component")]
    public GameObject DynamicMessageAndType;

    [Space(8), HideLabel]
    [InfoBox("Change GameObject value to update message type", InfoMessageType.None)]
    public InfoMessageType MessageType;

    [Space(12), HideLabel]
    [Title("Dynamic default message", "Use $ to indicate a member string as default message")]
    [ValidateInput("AlwaysFalse", "$Message", InfoMessageType.Warning)]
    public string Message = "Dynamic ValidateInput message";

#if UNITY_EDITOR // Editor-related code must be excluded from builds
    private bool AlwaysFalse(string value) {
        return false;
    }

    private bool MustBeNull(MyScriptyScriptableObject scripty) {
        return scripty == null;
    }

    private bool HasMeshRendererDefaultMessage(GameObject gameObject) {
        if (gameObject == null) return true;

        return gameObject.GetComponentInChildren<MeshRenderer>() != null;
    }

    private bool HasMeshRendererDynamicMessage(GameObject gameObject, ref string errorMessage) {
        if (gameObject == null) return true;

        if (gameObject.GetComponentInChildren<MeshRenderer>() == null) {
            // If errorMessage is left as null, the default error message from the attribute will be used
            errorMessage = "\"" + gameObject.name + "\" must have a MeshRenderer component";

            return false;
        }

        return true;
    }

    private bool HasMeshRendererDynamicMessageAndType(GameObject gameObject, ref string errorMessage, ref InfoMessageType? messageType) {
        if (gameObject == null) return true;

        if (gameObject.GetComponentInChildren<MeshRenderer>() == null) {
            // If errorMessage is left as null, the default error message from the attribute will be used
            errorMessage = "\"" + gameObject.name + "\" should have a MeshRenderer component";

            // If messageType is left as null, the default message type from the attribute will be used
            messageType = this.MessageType;

            return false;
        }

        return true;
    }
#endif
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1938805.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

【学习笔记】无人机系统(UAS)的连接、识别和跟踪(八)-无人机探测与避让(DAA)机制

目录 引言 5.6 探测与避让&#xff08;DAA&#xff09;机制 5.6.1 基于PC5的探测与避让&#xff08;DAA&#xff09;机制 引言 3GPP TS 23.256 技术规范&#xff0c;主要定义了3GPP系统对无人机&#xff08;UAV&#xff09;的连接性、身份识别、跟踪及A2X&#xff08;Airc…

HP ilo4服务器硬件监控指标解读

随着企业IT架构的复杂化&#xff0c;服务器的稳定性和可靠性成为保障业务连续性的关键因素。HP ilo4作为HP服务器的一个重要组件&#xff0c;提供了强大的远程管理和监控功能。本文将对使用监控易软件通过HP ilo4进行服务器硬件监控的指标进行解读&#xff0c;帮助运维团队更好…

数学建模-----SPSS参数检验和非参数检验

目录 1.参数检验 1.1独立样本t检验案例分析 1.1.1查看数据编号 1.1.2确定变量所属类型 1.1.3选项里面的置信区间 1.1.4对于结果进行分析 1.2配对样本t检验案例分析 1.2.1相关设置 1.2.2分析结果 2.非参数检验 2.1对比分析 2.2非参数检验的方法 2.3案例分析 2.3.1相…

Codeforces Round 960 (Div. 2)(A~C)题

A. Submission Bait 思路: 如果最大值有奇数个显然Alice赢&#xff0c;否则只需要看排序后是否存在n−i1是否为奇数且ai>ai−1即可。 代码: #include<bits/stdc.h> using namespace std; #define N 2000010 typedef long long ll; typedef unsigned long long ull; …

KMeans等其他聚类算法

KMeans算法是一种经典的聚类方法&#xff0c;最早由Stuart Lloyd在1957年提出&#xff0c;并在1982年由J. MacQueen推广和普及。虽然KMeans已经有几十年的历史&#xff0c;但它依然是数据挖掘和机器学习领域中最常用的聚类算法之一。 数学原理 KMeans算法的目标是将数据集分成…

Blender中的重拓扑修改器如何使用?

许多人还不了解Blender中的重拓扑编辑器及其使用方法。Blender中的重拓扑修改器提供了一系列工具和选项&#xff0c;以简化创建优化网格的过程&#xff0c;无论是出于何种目的&#xff0c;都能为3D艺术家和建模者节省大量时间和精力。那么&#xff0c;在Blender中重拓扑的定义是…

springcloud-config客户端启用服务发现报错找不到bean EurekaHttpClient

背景 在对已有项目进行改造的时候&#xff0c;集成SpringConfigStarter&#xff0c;编写完bootstrap.yml&#xff0c;在idea 启动项中编辑并新增VM options -Dspring.cloud.config.discovery.enabledtrue&#xff0c;该版本不加spring不会从configService获取信息&#xff0c;…

网络结构-组件-AI(九)

深度学习网络组件 RNN公式讲解计算示意图讲解 CNN计算示意 Normalization(归一化层)Normalization常见两种方式 Dropout层 RNN 循环神经网络&#xff08;recurrent neural network&#xff09; 主要思想&#xff1a; 即将整个序列划分成多个时间步&#xff0c;将每一个时间步的…

OrangePi AIpro 快速上手初体验

开发板开箱 1.1.包装 1.2.开发版 Orange Pi AIpro Orange Pi官网-香橙派&#xff08;Orange Pi&#xff09;开发板 1.3.引脚分布 1.4开发板资源简介 1CPU配备了4核64位ARM处理器&#xff0c;其中默认预留1个给AI处理器使用NPU集成了华为昇腾310BAI处理器&#xff0c;拥有4TF…

(二)原生js案例之数码时钟计时

原生js实现的数字时间上下切换显示时间的效果&#xff0c;有参考相关设计&#xff0c;思路比较难&#xff0c;代码其实很简单 效果 代码实现 必要的样式 <style>* {padding: 0;margin: 0;}.content{/* text-align: center; */display: flex;align-items: center;justif…

华为OD机试(C卷,200分)- 二叉树计算

题目描述 给出一个二叉树如下图所示&#xff1a; 请由该二叉树生成一个新的二叉树&#xff0c;它满足其树中的每个节点将包含原始树中的左子树和右子树的和。 左子树表示该节点左侧叶子节点为根节点的一颗新树&#xff1b;右子树表示该节点右侧叶子节点为根节点的一颗新树。…

笔记:Few-Shot Learning小样本分类问题 + 孪生网络 + 预训练与微调

内容摘自王老师的B站视频&#xff0c;大家还是尽量去看视频&#xff0c;老师讲的特别好&#xff0c;不到一小时的时间就缕清了小样本学习的基础知识点~Few-Shot Learning (1/3): 基本概念_哔哩哔哩_bilibili Few-Shot Learning&#xff08;小样本分类&#xff09; 假设现在每类…

【Linux】基础I/O——动静态库的制作

我想把我写的头文件和源文件给别人用 1.把源代码直接给他2.把我们的源代码想办法打包为库 1.制作静态库 1.1.制作静态库的过程 我们先看看怎么制作静态库的&#xff01; makefile 所谓制作静态库 需要将所有的.c源文件都编译为(.o)目标文件。使用ar指令将所有目标文件打包…

Linux应用——网络基础

一、网络结构模型 1.1C/S结构 C/S结构——服务器与客户机&#xff1b; CS结构通常采用两层结构&#xff0c;服务器负责数据的管理&#xff0c;客户机负责完成与用户的交互任务。客户机是因特网上访问别人信息的机器&#xff0c;服务器则是提供信息供人访问的计算机。 例如&…

[2019红帽杯]Snake

[2019红帽杯]Snake-CSDN博客 unity的题 下载下来看看是什么类型就是 这道题就是贪吃蛇 unity无脑找Assembly 用dnspy打开 一般就在这里慢慢找 但是你可以发现没有任何的信息 这里外接库 只能从这里下手试试 64位链接库的意思 游戏题,win!很关键 进入了Gameobject 看a1,小…

复现Android中GridView的bug并解决

几年前的一个bug&#xff0c;GridView的item高度不一致。如下图&#xff1a; 复现bug的代码&#xff1a; import android.os.Bundle; import android.widget.BaseAdapter; import android.widget.GridView; import androidx.appcompat.app.AppCompatActivity; import java.uti…

【Day12】登录认证、异常处理

1 登录 先创建一个新的 controller 层&#xff1a;LoginController RestController public class LoginController {Autowiredprivate EmpService empService;// 注入PostMapping("/login")public Result login(RequestBody Emp emp) { // 包装对象Emp e empServic…

html 单页面引用vue3和element-plus

引入方式&#xff1a; element-plus基于vue3.0&#xff0c;所以必须导入vue3.0的js文件&#xff0c;然后再导入element-plus自身所需的js以及css文件&#xff0c;导入文件有两种方法&#xff1a;外部引用、下载本地使用 通过外部引用ElementPlus的css和js文件 以及Vue3.0文件 …

Golang | Leetcode Golang题解之第260题只出现一次的数字III

题目&#xff1a; 题解&#xff1a; func singleNumber(nums []int) []int {xorSum : 0for _, num : range nums {xorSum ^ num}lsb : xorSum & -xorSumtype1, type2 : 0, 0for _, num : range nums {if num&lsb > 0 {type1 ^ num} else {type2 ^ num}}return []in…

【数据结构】二叉树OJ题_对称二叉树_另一棵的子树

对称二叉树 题目 101. 对称二叉树 - 力扣&#xff08;LeetCode&#xff09; 给你一个二叉树的根节点 root &#xff0c; 检查它是否轴对称。 示例 1&#xff1a; 输入&#xff1a;root [1,2,2,3,4,4,3] 输出&#xff1a;true示例 2&#xff1a; 输入&#xff1a;root [1,2…