近期回归程序行业,由于业务需求需要做十三水游戏,什么是十三水就不在多讲,下面是判断十三水牌型的方法(带大小王)
GetSSSPaiType {};
local this GetSSSPaiType;
local huaseTable {};
local numTable {};
functi…
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;/// <summary>
/// 渐变色image
/// </summary>
[RequireComponent(typeof(Image))]
public class UIImageGradient : BaseMeshEffect
{public UnityEngine.Gradient gradientColor n…
Unity 使用Visual Studio Code 调试C# PackageManager安装Visual Studio EditorVisual Studio Code安装Unity 插件修改Unity配置调试 PackageManager安装Visual Studio Editor
打开 Window->PackageManger卸载 Visual Studio Code Editor ,这个已经被官方废弃安…
这段代码用于读取表格
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OfficeOpenXml;
using System.IO;
using UnityEngine.Networking;
using UnityEngine.UI;
using Random UnityEngine.Random;public class Plots…
今天使用UnityHub打开Unity项目,会有一个弹窗提示:Sentinel key not found (H0007)。什么也没有操作就突然不能打开了,记录一下解决办法。
1.先删除C:\ProgramData\SafeNet Sentinel ProgramData是一个默认隐藏…
感谢https://www.cnblogs.com/ggll611928/p/15726839.html using Unity.Plastic.Newtonsoft.Json.Linq;
using Unity.Plastic.Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
u…
客户端 接收端 :
using System;
using System.IO;
using System.Collections;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Text;
using System.Threading;
using UnityEngine;
using UnityEngine.UI;public cla…
// 检测鼠标左键的点击事件 if (Input.GetMouseButtonUp(0)) { RaycastHit hit; Ray ray Camera.main.ScreenPointToRay(Input.mousePosition); // 创建射线从相机指向鼠标点击位置 if (Physics.Raycast(ray, out hit)) // 如果射线击中了物体{GameObject clickedObject hit.…
1. 在场景中添加事件系统
2. 为主相机添加射线检测 3. 为物体挂载以下脚本,物体必须带碰撞体 using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;// 挂在物体上,需要添加碰撞体
public …
c#脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class PoleMove : MonoBehaviour
{//移动上限制public float up;//移动下限public float below;//速度private float speed;// Start is called before the first frame update…
在Unity中,使用键盘ADWS键控制物体移动,通过鼠标左键控制物体旋转,鼠标中键控制物体缩放是再常见不过的方法。
方法如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class MoveCo…
在场景创建一个Cube,并添加刚体,如图: 编写脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;[RequireComponent(typeof(Rigidbody))]
public class RibRotate : MonoBehaviour
{//private Vector3 mo…
AI Navigation导航系统 安装插件烘焙导航系统障碍物创建人物的AI导航动态障碍物 在unity编辑器中,有一个灰常好用的插件:Navigation。有了它1,你就可以实现人物自动走到你鼠标点击的位置,而且还会自动避开障碍物,下面就…
首先装包 先给地图 和 阻挡 设置为静态 然后给地上行走的地方 添加组件 可以直接bake 然后会显示蓝色的可行走路径
player 添加插件 然后给角色添加脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class PlayerMove : Mon…
GitHub - EnoxSoftware/VideoPlayerWithOpenCVForUnityExample: This example shows how to convert VideoPlayer texture to OpenCV Mat using AsyncGPUReadback. OpenCV for Unity | Integration | Unity Asset Store
There are 2 audio listeners in the scene. Please ensure there is always exactly one audio listener in the scene.
从组件中找出包含 Audio Listener 的,只激活一个,其他的关掉
Unity 3D Color 控件与 Background Color 控件类似,都是渲染 GUI 颜色的,但是两者不同的是 Color 不但会渲染 GUI 的背景颜色,同时还会影响 GUI.Text 的颜色。具体使用时,要作如下定义:public static var color:Color;…
按照比例设置目标分辨率:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class CurrentScreenResolution : MonoBehaviour
{public Text intfoText;[Header("分辨率 Width")]public flo…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;/**UI特效遮罩
1.需要将ScrollRect 的遮罩Mask 换为 2D Mask2.将特效的Render里面的 Masking 设置为*/
public class UIParticleMaskControll : MonoBehaviour
{// Start is called before …
根据BRDF公式,高光项部分,只能物体的表面的粗糙度有关。Roughness有关
大部分公式都是 根据Cook-Torrance 的微表面高光BRDF公式 我们把高光分成三项
D项
Normal Distribution Function (NDF) 法线分布函数 Unity PBS1 就使用GGX(Trowbrige-Reitz) 上…
unity 相机围绕物体旋转,并且有Y轴角度限制,可通过parameters.offset 修改使目标物不在画面中心
using UnityEngine; using System.Collections; using System.Collections.Generic; using UnityEngine.EventSystems; using UnityEngine.UI;
public cl…
目录
前言
Unity的一个单位
Camera Size
Pixel Per Unit的具体含义 前言
unity 2d中的sprite ,具有一个参数:Pixel Per Unit
初学者往往不知道这个代表什么意思,如何理解,怎么设置,这个在unity的美术素材的使用也…
class Newtonsoft.Json.Linq.JToken e CS0433:类型"JToken"同时存在于"Newtonsoft.Json.Net20,Version3.5.0.0,Cultureneutral,,PublicKeyToken30ad4fe6b2a6aeed"和"Newtonsoft.Json, Version12.0.0.0,Cultureneutral,PublicKeyToken30ad4fe6b2a6aeed…
文章目录The following modules are missing or built with a different engine versionXXX could not be compiled. Try rebuilding from source manaually添加组件时提示未定义标识符或函数名法一方法二方法三The following modules are missing or built with a different e…
hastexture 这个api好像有问题 getTexture替代 HasProperty这个比较好 新版URP貌似已经有了 using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEditor;
using UnityEngine;public class ConvertURPLit : EditorWindow
{p…
本文为Google Translate英译中结果,DrGraph在此基础上加了一些校正。英文原版页面:
Learning new features — Godot Engine (stable) documentation in English
学习新功能
Godot 是一个功能丰富的游戏引擎。有很多关于它的知识。本页介绍了如何使用…
psd文件保留原树节点和位置信息导入unity 该插件资源只能用于学习不得商用
官方商店下载链接Psd 2 uGUI Pro | GUI Tools | Unity Asset StoreUse the Psd 2 uGUI Pro from auiWorks on your next project. Find this GUI tool & more on the Unity Asset Store.https://a…
在streamingAssets文件夹或其他文件夹下新建txt文件, 代码部分 using System.Collections;
using System.Collections.Generic;
using System.IO; //文件处理命名空间
using UnityEngine;
public class Test : MonoBehaviour
{
public string s;void Start(){strin…
Unity中使用代码选中对象(Ping)
大家都知道, 在Unity Editor中双击选中对象可以快速定位资源, 如图片, 预制等.
那么怎么通过代码来做到呢, 其实很简单, 就是一句调用:
// Ping an object in the Scene like clicking it in an inspector.
// 就像在属性面板中点击一样(Ping…
unity 双击物体让其显示,再次双击让其隐藏 using System.Collections; using System.Collections.Generic; using Unity.Burst.CompilerServices; using UnityEngine;
public class ToggleObjects : MonoBehaviour { private float lastClickTime 0f; private flo…
Ps:主要解决耦合问题,把脚本之间的联系通过不同消息类型事件形式进行贯通
1.MessageCenter主脚本
2.DelegateEvent消息类型脚本
3.MC_Default_Data具体接收类脚本 using System;
using System.Collections;
using System.Collections.Generic;
using …
1. ORB_SLAM3深度学习开源调研 ORB-SLAM3 with Docker:https://github.com/petrikvladimir/orbslam3-docker 特点:ORB-SLAM3 with Docker是一种基于Docker容器的ORB-SLAM3版本,具有更好的可移植性和便捷性。 改进点:使用Docker容器…
Material:划线的材质
Positions:多个点,划线的点集
Use World Space:是否使用世界坐标系
Loop:是否循环,是指第一个点和最后一个点是否形成闭环
Width:划线的宽度,通过曲线来控制…
官方地址 https://docs.unity3d.com/cn/2022.2/Manual/SL-MultipleProgramVariants.html 教程可以看这里 https://www.jianshu.com/p/48ad75f0b4b9 https://www.jianshu.com/p/3e6b84317097
变种用我自己的理解就是 能用程序控制的shader
举个例子 这里声明了 a b c d 四个变…
创建窗口
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor; public class CreateTrees : EditorWindow
{[MenuItem("Window/My Window1")]static void Init(){CreateTrees window (CreateTrees)GetWindow(type…
正常来说,VS Code中会对部分输入类名进行提示,如下图所述
假如你从Unity 中进入 VS Code后发现没有提示相关 Unity的类,可能是 Unity 中 有关于 VS Code的相关Package 没有跟着 VS Code升级到最新版本。
点击Unity Windows 下拉框中的 Pac…
1.在场景中新建两个 Cube 立方体,在 Scene 视图中将两个 Cude的位置错开。 2.新建 C# 脚本 Distance.cs(写完记得保存)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Distance : MonoBehav…
Overload引擎地址: GitHub - adriengivry/Overload: 3D Game engine with editor 一、栅格绘制基本原理
Overload Editor启动之后,场景视图中有栅格线,这个在很多软件中都有。刚开始我猜测它应该是通过绘制线实现的。阅读代码发现࿰…
HotReload For Unity的文档的导航的翻译,很垃圾
文档路径:https://hotreload.net/documentation/getting-started 使用的Unity版本:2020,2021,2023 使用的插件版本 1.2.4
Getting Started (开始)
Open H…
这段代码用于读取表格
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using OfficeOpenXml;
using System.IO;
using UnityEngine.Networking;
using UnityEngine.UI;
using Random UnityEngine.Random;public class Plots…
unity 通过Andriod arr 访问 手机自带的浏览器
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.UI;public class OpenURL : MonoBehaviour
{public Button button;string url "http://192.168.1.…
UE4 stat 命令
这里是记录了所有 stat 命令的列表:https://docs.unrealengine.com/en-US/Engine/Performance/StatCommands/index.html
stat fps:每秒帧数(FPS)和每帧毫秒数的 unobtrusive view(不显著视图)。 stat unit:更详细版本的stat fps: Frame:完成每帧的总时…
项目目录:D:\GIT\YooAsset\Temp 收集代码:
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
#if UNITY_EDITOR
using UnityEditor.Build;
using UnityEditor.Rendering;
#if UNITY_2019_4_OR_NEWER
using UnityEditor.Build.Pipeline…
文章目录 前言一、我们对 Standard 的 PBR 的 GI 进行解析1、我们先创建一个PBR的.cginc文件,用于整理用到的函数2、然后在Standard的Shader中引用该cginc文件 二、依次整理函数到该cginc文件中我们来看一下PBR中GI的镜面反射做了些什么 二、最终代码.cginc代码&…
序
有的时候,执行某些脚本时会有先后顺序的要求。unity是按什么顺序来执行脚本的?如何设置?
默认的执行顺序
官方文档里面有个很长的图:
Unity - Manual: Order of execution for event functions (unity3d.com) 根据文档&…
相比之前的图像物体检测,这脸部检测实现起来会更加的简单。
(1)首先我们先在场景中的物体上添加一个AR Face Mananger组件: (2)以上組件的 Face Prefab所代表的就是脸部的模型也就是覆盖在脸部上面的投影模…
有时候我们在做一些类似轮播的效果时,就通常会用到切换某张图片显示在最后端或者最前端。
如我写一个这样的脚本:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class ChangePic : M…
文章目录 前言一、逆矩阵的表示二、逆矩阵的作用四、逆矩阵的计算五、顺序的重要性六、矩阵的逆总结1、求矩阵的逆前,这个矩阵必须得是个方阵2、只有 A x A ^-1^ A^-1^ x A 1时,A的逆才是A^-1^3、求2x2矩阵的逆:交换 a 和 b 的位置…
Unity 中要获取物体的子物体,可以使用以下一些方法。
1、只获取一级节点的子物体: public Transform tran;// Start is called before the first frame updatevoid Start(){foreach (Transform child in tran){Debug.Log(child.name);}}
使用该方法只会…
文章目录 前言一、本地空间怎么转化到观察空间二、怎么得到观察空间的基向量1、Z轴向量2、假设 观察空间的 Y~假设~ (0,1,0)3、X Y 与 Z 的叉积4、Y X 与 Z 的叉积 三、求 [V~world~]^T^1、求V~world~2、求[V~world~]^T^ 四、求出最后在Unity中使用的公式1、偏移坐标轴2、把…
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine; public class SavePS : MonoBehaviour
{private string logFilePath "positions.txt"; // 保存日志的文件路径 private TextWriter writer; // 用于写入文件…
环境搭建
正常运行 Android 端的 Cocos2d 项目,本机至少需要 Android SDK、NDK 环境、Android Studio
项目报错总结
CMake Error: CMake was unable to find a build program corresponding to "Ninja" 默认创建工程的 gradle.tools 版本为 3.1.0&…
1. 获得深度纹理
在unity中获取深度纹理是比较简单的,通过将脚本挂在摄像机上,代码如下,参考自UnityShader入门精要.
用于生成材质的一个基类:
using UnityEngine;
using System.Collections;[ExecuteInEditMode]
[RequireComp…
在修改器下面把control点开,表示ctrl加空格键可以实现超级跳。 do once节点表示只能运行一次 在添加冲量节点之后再次添加一个延迟节点(delay),把completed接回到do once 的reset 给一个三秒钟的延迟。实现技能冷却。
工程Asset下新建Editor文件夹; Editor文件夹下新建脚本LogPosition
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class LogPosition : EditorWindow
{//最终输出的数据.static string logtext;//增…
在Windows安装Airsim/UE4踩坑合集 1.安装过程中一定要确保Epic Games Launcher是英文环境,保存路径什么的也尽量是英文。2.UE4中的虚幻引擎一定要安装4.27版本以上的,不然的话最后运行vs的时候会报语法错误,网上根本查不到的那种错误。换了版…
依赖于UniTask(访问Github)依赖于Addressable资源管理(通过UPM安装)
using Cysharp.Threading.Tasks;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.ResourceMana…
创建场景
放上一个plane,放上一个球 sphere,假定我们的球就是我们的玩家,使用控制键w a s d 来控制球也就是玩家移动。增加一个材质,把颜色改成绿色,把材质赋给plane,区分我们增加的白球。
增加组件和脚…
1.Unity Prefab Apply All 设置快捷键,修改预设体之后快捷键应用 打包会出问题:The type or namespace name ‘EditorWindow‘ could not be found EditorWindow类无法打包出EXE 添加unity关键字定义如下文所示: #if UNITY_EDITOR using Uni…
文章目录 前言一、Phong光照模型二、图示解释Phone光照模型1、由图可得,R 可以由 -L 加上 P 得出2、P等于2*M3、因为 N 和 L 均为单位向量,所以 M 的模可以由 N 和 L得出4、得到M的模后,乘以 单位向量N,得到M5、最后得出 P 和 R 前…
using System.Collections; using System.Collections.Generic; using UnityEngine; public class Collider_Class : MonoBehaviour { // 用于Collider类的测试 public GameObject OneBullet; Transform Father; void Start () { Father GameObject.FindGameObjectWithTag(&qu…
Unity在Windows选项下没有Auto Streaming Unity Auto Streaming插件按网上说的不太好使最终解决方案 Unity Auto Streaming插件
我用的版本是个人版免费版,版本号是:2021.2.5f1c1,我的里边Windows下看不到Auto Streaming选项,就像下边这张图…
文章目录 前言一、人眼对光照的自适应1、光照强度与人眼所见的关系2、巧合的是,早期的电子脉冲显示屏也符合这条曲线3、这两条曲线都巧合的符合 y x^2.2^(Gamma2.2空间) 二、Gamma矫正1、没矫正前,人眼看电子脉冲显示屏ÿ…
204. 语句
在上一篇,我们接触了三种常见的类型,如下所示: 这样我们算是对变量进行了一个入门了。
其实我们除了变量,我们还接触了一个叫做语句的概念。
我们可以看下代码:
extends Node# Called when the node enters the sce…
常见的游戏机制
Actor机关门 创建一个Actor类,添加两个静态网格与一个触发器 UBoxComponentUStaticMeshComponent 头文件: #include “Components/BoxComponent.h”#include “Components/StaticMeshComponent.h”
TriggerDoor.h
// Fill out your …
1.背景音乐作为一个独立的节点: 2.通过Url加载背景音乐:运行后添加AudioSource组件
using DG.Tweening;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Analytics;
using UnityEng…
IK(反向动力学)有利于提升 VR 应用中的沉浸感,比如我们可以通过对手部的追踪,再结合 IK,来模拟 VR 中人物的手臂和手肘的姿态。
Final IK 是 Unity 一款功能强大的 IK 插件,其中拥有适用于 VR 的 IK 功能&…
文章目录 简述Screen Space - Overlay优点缺点 Screen Space - Camera优点缺点 World Space优点缺点 简述
用Unity中开发了很久,但是对unity UI管理中Canvas组件的Render Mode有三种主要类型:Screen Space - Overlay、Screen Space - Camera和World Spa…
之前一直不知道如何才能让OnMouseDown生效,试来试都没反应,后来才发现需要添加BoxCollider2D控件(记得设置Size,否则无效)才行,记录一下
public class Test : MonoBehaviour
{private void OnMouseDown(){…
目录
报错:
分析:
1.代码剔除等级设置
2.什么方式会被剔除
3.解决办法 报错:
FileNotFoundException: Could not load file or assembly XXX or one of its dependencies at System.AppDomain.Load (System.String assemblyString, Sys…
Unity对象池创建对象池基类创建宝石对象池创建物体脚本创建对象池控制器在unity的2021版本后,Unity引入了对象池,从这以后就可以用Unity内置的对象池,这次我们就来演示一下Unity内置的对象池。创建对象池基类
using System.Collections;
usi…
Animation Blending 两个动画衔接
Math of blending:LERP:线性插值 在两个动画之间取关键帧插值 weight1weight2等于1 两个动画必须都是循环的,归一化之后能一致 Blend Space 在采用空间里的所有动画(clips)…
UI 卡牌翻转效果
鼠标进入显示反面,鼠标离开显示正面。
脚本
using UnityEngine;
using DG.Tweening;
using UnityEngine.UI;
using UnityEngine.EventSystems;
/// <summary>
/// 鼠标进入:显示反面;鼠标离开:显示正面…
组件都是在某个游戏物体身上挂载的,因此可以通过游戏物体查找获取后使用 首先创建一个游戏物体GameObject01,然后添加一个脚本组件Component1
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Component1 : MonoBeh…
效果: 场景结构: 特殊物体:panel下面用排列组件horizent layout group放置多个需要显示的面板,用mask遮罩好。 using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using UnityEngine;
using Unity…
查看vscode的output窗口,提示加载 csproj 文件失败
It need be converted to new SDK style to work in C# Dev Kit.
把unity的PackageManager里的 Visual Studio Editor 版本升级到2.0.20或以上,重新生成csproj文件就好了。
参考vscode官方ÿ…
Unity添加所有场景到BuildSettings
using UnityEngine;
using UnityEditor;
using System.Collections.Generic;
using System.IO;
public class Tools : Editor
{[MenuItem("Tools/添加所有场景到BuildSettings")]static void CheckSceneSetting(){List<string&…
现在遇到一个需求,用Unity里用图片生成Gcode
告知硬件让它去画出来
翻阅了一些资料,最后决定用OpenCV去做
下图左侧是生成的Gcode文件 右侧是要画的图片 话不多说直接上代码
using System.IO;
using UnityEngine;
using OpenCVForUnity.CoreModule;
…
紫色原因是因为编辑器内跑了其他平台的shader兼容性导致的,需要动态的去修改shader,主要用到Unity的api : Shader.Find(shaderName);
具体的工具代码如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine…
public void MatrixTest1(){ ///Matrix4x4 是列矩阵,就是一个vector4表示一列,所以在c#中矩阵和Vector4只能矩阵右乘坐标。但是在shader中是矩阵左乘坐标,所以在shader中是行矩阵 Matrix4x4 moveMatrix1 new Matrix4x4(new Vector4(1,0,0,0)…
c# 的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;public class GraphicsBlitTest : MonoBehaviour
{public Texture2D source;//原纹理public Material material;//效果材质public RawImage rawImage;// Sta…
1、挂载脚本到角色的父物体A上
2 、以屏幕左边的触摸为移动,右边为转向操作
3、加载角色时,将角色的父物体设置为A,须将角色的位置和角度置0 using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngin…
替换脚本PlayerCam_01.cs using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;public class PlayerCam_02 : MonoBehaviour
{// 视觉灵敏度参数public float sensX 400;public float sensY 400;// 视角垂直旋转角度限制publ…
文章目录 前言一、Unity中Shader的面是否剔除,是由我们自己决定的二、暴露一个属性来控制 剔除模式三、如何区分正反面 前言
Unity中Shader的面剔除 Cull Off | Back | Front 一、Unity中Shader的面是否剔除,是由我们自己决定的 使用 Cull Off | Back |…
文章目录 🟥 UMA Data DNA参数引用位置🟥 UMA API介绍🟥 UMA Data DNA参数引用位置
我们想通过代码去控制如图所示参数,达到捏脸的目的.下面就是可以控制的代码:
_dna["headSize"].Set(1);
_avatar.BuildCharacter();我们观察发现操控代码类似Material去设置…
Overload引擎地址: GitHub - adriengivry/Overload: 3D Game engine with editor 一、栅格绘制基本原理
Overload Editor启动之后,场景视图中有栅格线,这个在很多软件中都有。刚开始我猜测它应该是通过绘制线实现的。阅读代码发现࿰…
如果你已经走到了其他教程的最后一步,出现报错
Connection failed.Ensure the device is connected and the correct version (4.1) of Leap Motion driver is installed
直接跳到最后一节就能解决
一、LeapMotion硬件
硬件部分很简单,就和手机数据线…
目录 前言
方法 前言
本文解决自定义unity运行时输出的分辨率的问题
方法
将以下代码修改输出和分辨率后,挂载在空物体上即可 using System.Collections; using System.Collections.Generic; using UnityEngine; public class ActiveDisplay : MonoBehaviour { …
目录 0 引言1 直接蓝图通信1.1 在关卡蓝图中直接拖拽Actor1.2 Get Actor of Class/Get All Actors of Class 2 事件分发器2.1 创建事件分发器2.2 绑定事件分发器2.3 调用事件分发器 3 蓝图接口3.1 使用步骤3.2 为什么要使用蓝图接口 4 蓝图转换 0 引言 问题:为什么需…
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Trackracecomplete : MonoBehaviour { /// /// 数字图片 /// [SerializeField] private Sprite[] sprites; private string _Time “23:57:49”; [Ser…
目前,Unity云渲染虽然没有正式发布,但是功能还是满足大部分需求。官方地址:GitHub - Unity-Technologies/UnityRenderStreaming: Streaming server for Unity
我也摸了一段时间了,里面有这些功能发现还是可以用的:
1…
文章目录 一、序列化二、反序列化 一、序列化
(一)声明类对象
如果要使用 C# 自带的序列化 2 进制方法,申明类时需要添加[System.Serializable]特性。
[System.Serializable]
public class Person
{public int age 1;public string na…
Collider2D Material:物理材质
Used by effect、Used by Composite:用于效应器
Rigidbody 2D Simulated:是否计算重力 Sleeping Mode:休眠的模式 Never Sleep:从不休眠 Start Awake:开始即激活 Start Asl…
汇总一些Unity Editor开发的常用方法和实现方式,会持续更新。
添加自定义菜单栏方法 using UnityEngine;
using UnityEditor;public class EditorTools : EditorWindow
{[MenuItem("EditorTools/自定义的编辑器方法")]public static void CustomEditroFu…
观察场景中Main Camera 的清除背景Clear Flags 第一种:Skybox天空盒渲染 制作3D游戏使用 第二种:Solid Color 制作2D游戏 第三种:Depth only 多个摄像机叠加渲染 相对重点学会多个摄像机设置Depth only使…
1、打包
在这个界面左边右键,CreateNewBundle 将要打包的模型制作成预设体
在下面勾选 选好平台路径,点击Build
2、加载AB包
public class ABTest : MonoBehaviour
{// Start is called before the first frame updatevoid Start(){//加载AB包AssetB…
报错: Decompressing this format (49) is not supported on this platform.
Unable to read header from archive file: D:/UnityProject/SeacostStory/SeacoastStory/Assets/StreamingAssets/c0db063e4f87039a5251af6a17e253ae.unity3d 原因
Character Movement Replication 角色位移同步 玩家2的视角看玩家1的移动是起伏一截一截,并且滞后的 interpolation:内插值,在两个旧的但已知的状态计算 extrapolation:外插值,本质是预测 内插值:但网络随着…
因为需要用到unity和其他的程序交互,其他程序可以提供Udp消息,因此找了合适的相互连接方法。这里直接上代码。
工具类:
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Net;
u…
记录!Unity Inspector面板编辑器扩展,枚举显示中文,枚举值自定义显示内容,显示部分选项。效果如下: 枚举类代码:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public…
一.优化最终效果及消耗 8人同屏,最高画质,耗时1.1ms(高通 骁龙710)。因为项目未上线原因,只能用测试图进行相关说明。 二、原反射脚本源码 1. 源码
using UnityEngine;
using System.Collections;[Execute…
第一部分:Xlua调用C#
--Lua获取C#类
local GameObjectClass CS.UnityEngine.GameObject--使用C#类New新对象
local newGameObj GameObjectClass(helloworld)
print(GameObjectClass, newGameObj)--调用C#类的静态方法
local FindObj GameObject.Find(helloworld…
系列文章目录 文章目录系列文章目录前言🍇一、游戏:射击敌人(Game: Shoot the enemy)🍈二、任务:创建一个移动的熊猫(Task: Create a moving panda)🍑三、任务:创造一个移动的蛇(Tas…
系列文章目录 文章目录系列文章目录前言🍇一、图像(Images)1️⃣.图像(Images)🍈二、draw()参数1️⃣.draw()参数2️⃣.图像(image)3️⃣.x轴和y轴4️⃣.旋转角度rotate5️⃣.x-scale方向大小 and y-scale方…
1.需求 给物体绑定一个脚本,这个脚本实现物体的透明度渐变变化,并且可以重置回原来的颜色。物体为Unity自带的材质Shader为Standard。
2.代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Transpare…
取个巧,利用Camera和Render Texture 多个2d图片组合成型 每个Square都单独设置一个层级 相机设置 RenderTexture设置,然后将RenderTexture放在一个RawImage上
以下是生成图片的代码 using UnityEngine.UI;
using System.Collections;
using System.…
代码和预制体 函数PlayAnim()中的角度要根据按钮数量手动填好
using System;
using DG.Tweening;
using DG.Tweening.Core;
using DG.Tweening.Plugins.Options;
using UnityEngine;// Token: 0x0200001B RID: 27
public class BtnParentScript : Base…
unity每次编辑代码的时候,都需要保存,unity右下角的小圆圈总是转个不停,那么每次编辑代码后,unity到底需要多久时间呢,下面就有代码可以获取 保存时间。 using UnityEngine;
using UnityEditor;
using UnityEditor.Com…
本周六(12月17日)下午14:00,Cocos Star Meetings「成都站」将以线上直播的形式与大家见面!点击下方立即「预约」吧 ↓↓↓本次成都站,刀锋游戏开发工程师虣虣,活跃在社区论坛的研发大佬马赛克、wing 将分享…
使用LineRender组件画物体的包围盒线框 转载:Unity学习——LineRender画物体的立方体框_Alxes_七局的博客-CSDN博客 public Material Mater;public Material Mater1;private LineRenderer line;//8个顶点#region MyRegion//private Vector3 v1 new Vector3(-0.5f, …
系列文章目录 文章目录系列文章目录前言🍇一、角度(Angle)🍊二、正弦和余弦(Sine and cosine)🍑三、距离(Distance)🍈四、图像(Image)…
系列文章目录 文章目录系列文章目录前言🍇一、分享你的游戏(Distributing your game)🍊二、castle🍌三、总结🍋总结前言 🍇一、分享你的游戏(Distributing your game) 我…
Post Processing(后期处理)并不属于特效,但现代的特效表现离不开后期处理的支持。本文以眩光(Bloom)为例,展示一种明亮的激光的制作方法 1、安装后期处理扩展包
较新的Unity版本已经内置了新版的后期处理扩…
系列文章目录 文章目录系列文章目录前言🍇一、Love2d是什么🍈二、Love2d的安装1️⃣.Love2d安装教程2️⃣.Love2d环境变量的配置🍉三、Love2d编辑器安装🍊四、验证Visual Studio Code配置🍋总结前言 🍇一、…
法1:调用外部Capi库
具体使用:
public class Ini{//读取INI文件需要调用C的APP[System.Runtime.InteropServices.DllImport("kernel32")]private static extern long WritePrivateProfileString(string section, string key, string val, st…
1. 状态机概念介绍
在Unity中,动画状态机(Animator State Machine)是一种强大的工具,用于控制游戏对象的动画行为。动画状态机由多个动画状态Animation和过渡条件Transition、层组成!而层(Layersÿ…
demo下载:https://github.com/JSumC/LanguageExcel
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using OfficeOpenXml;
using UnityEngine;
using UnityEngine.UI;
namespace LanguageExcel
{public class LETool : MonoBehaviour{…
1、创建文本
右键->create->ui->leagcy->text
2、设置字体 3、设置默认值和数字 4、当切换分辨率,分数不见问题
拖拽这里调整 调整到如下图
5、编写得分脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
…
文章目录 前言一、GPU实例化的规则1、网格一样,材质一样,但是材质属性不一样2、单个合批最大上限为511个对象3、只有OpenGL es 3.0及以上才支持(3.0及以上有部分硬件可能也不支持) 二、GPU实例化的应用场景1、公开几个成员属性&am…
在Unity中,有时候我们在处理数据的时候会用到结构体定义一些Unity组件相关的数据成员,并且需要在编辑器中拉取对象赋值。比如:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;publ…
一、效果 二、脚本及原理
1.卡牌控制脚本 主要负责射线检测卡牌,调用执行当前选择卡牌的进入、持续、离开后的一些功能操作 using System.Collections;
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.EventSyste…
一、c#脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Bling : MonoBehaviour
{public Texture img;public float speed;public static bool changeWhite false;private float alpha0f;// Start is called before the fi…
原理:bundle的依赖关系构建一个二维的矩阵图,如果对角线相互依赖(用1标记)则表示循环依赖。
using PlasticGui;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEditor;
public cl…
这个案例实现的动作并不复杂,主要包含一个 跳跃动作、攻击动作、还有一个包含三个动画状态的动画混合树。然后设置三个参数来控制切换。
状态机结构如下: 完整代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;pu…
1、新建c#脚本如下
代码,在前方生成生成自身图片并3s后销毁自身,在碰撞物体后小鸟死亡后不删除自身
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class CopyScene : MonoBehaviour { //要复制的对象public…
【背景】
Unity程序有时依赖于某些服务去实现一些功能,此时可能需要类似打开程序就自动运行Windows命令行命令的功能。
【方法】
using UnityEngine;
using System.Diagnostics;
using System.Threading.Tasks;
using System.IO;
using System.Text
unity API 之EventSystem.current.IsPointerOverGameObject()
命名空间 :UnityEngine.EventSystems
官方描述:
public bool IsPointerOverGameObject();
public bool IsPointerOverGameObject(int pointerId); //触摸屏时需要的参数ÿ…
因为我们使用了ILRuntime热更,unity 打出的WebGL包,运行就会报找不到DoTween里面的方法,所以吧DoTween拓展到tranform类里面,这样就不会报错了,下面是示例
using DG.Tweening;
using System.Collections;
using Syste…
一:前言 获取到选中的文字:哈哈 二:实现
UGUI的InputField提供了selectionAnchorPosition和selectionFocusPosition,开始选择时的光标下标和当前光标下标
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngin…
资料
Github cscore
注意
笔记本可直接使用麦克风,台式电脑可能需要耳机辅助
测试脚本
using UnityEngine;
using CSCore.SoundIn;
using CSCore.Codecs.WAV;
public class Recorder : MonoBehaviour
{private WasapiCapture capture;private WaveWriter write…
一、先说接口
接口是不能实例化的,想实例化接口,只能实例化继承了接口的类。
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;namespace InterfaceTest {interface IMyInterfa…
1.新建一个C#脚本,命名为 “SkipSplashScreen” (代码如下)。
using System.Collections;
using System.Collections.Generic;
using System;
using UnityEngine;
using UnityEngine.UI;#if !UNITY_EDITOR
using UnityEngine;
using UnityEn…
现在需求是将本地的图片读取之后再区域截图成新的图片 话不多说直接上代码
using UnityEngine;
using System.IO;public class LocalRegionCapture : MonoBehaviour
{public string fullScreenImagePath "Assets/SavedImages/fullScreenScreenshot.png";public str…
简单角色对话UI脚本的编写
新建UI,里边有两个文本组件一个按钮组件,一个展示名称,一个展示对话内容,按钮组件负责展示下一句对话。
public class DialogueUI : MonoBehaviour
{private TextMeshProUGUI nameTexe;//获取名称的T…
相关教程
把AI模型放入Unity-手写数字识别【UnitySentis入门-1】_哔哩哔哩_bilibili
Unity官方文档创建引擎以运行模型 |森蒂斯 |1.2.0-exp.2 (unity3d.com)
教程转载自:AI Tools for Game Dev 游戏开发人工智能工具/UnitySentis/01-Unity Sentis 入门.md chut…
直接上代码
using UnityEditor;
using UnityEngine;
using System.Collections.Generic;
using System.IO;
using OHGame;
using Unity.VisualScripting;public class OHEditorTool : Editor
{[MenuItem("OHGame/Tools/行动区域点落地")]private static void GetObj…
在Unity中,很多组件都带有事件,比如:
Button组件:onClick() Toggle组件:On Value Changed(Boolean)
Dropdown组件:On Value Changed(Int32)
InputField组件:On Value Changed(String)、On End Edit(Stri…
1.项目工程路径下创建文件夹:ABundles 2.AB包打包脚本: using System.Collections.Generic;
using System.IO;
using UnityEditor;
using UnityEditor.SceneManagement;
using UnityEngine;
using UnityEngine.SceneManagement;public class AssetBundle…
1.网络请求管理器 using LitJson;
using Cysharp.Threading.Tasks;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Events;using System.Web;
using System.Text;
using Sy…
在Unity中,如果要通过鼠标拖到UI组件或者触摸移动UI组件,可以使用EventSystems下的方法。
具体实现如下:
新建一个脚本,DragController.cs:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
…
1.下载安装UnityWebSocket 插件
https://gitee.com/cambright/UnityWebSocket/ 引入unity项目: 2.定义消息体结构:ExternalMessage和包结构Package:
using ProtoBuf;
using System;
using System.Collections;
using System.Collections.Ge…
导入ImGui:
下载链接:
GitHub - TheCherno/imgui: Dear ImGui: Bloat-free Immediate Mode Graphical User interface for C with minimal dependencies 新建文件夹,把下载好的文件放入对应路径: SRC下的premake5.lua文件&#…
RectTransform转屏幕坐标
分两种情况
Canvas渲染模式为Overlay时,使用此方式 public Rect GetScreenCoordinatesOfCorners(RectTransform rt)
{var worldCorners new Vector3[4];rt.GetWorldCorners(worldCorners);var result new Rect(worldCorners[0].x,world…
1、代码
public class UIManager
{private static UIManager instance new UIManager();public static UIManager Instance > instance;//存储显示着的面板脚本(不是面板Gameobject),每显示一个面板就存入字典//隐藏的时候获取字典中对…
库存模块主要参考了 youtube 上的视频
BMo 的 Flexible INVENTORY SYSTEM in Unity with Events and Scriptable Objects 和 Simple Inventory UI in Unity With Grid Layouts 这两个视频是一个系列
还是一个视频也是 BMo的 How To INTERACT with Game Objects using UNITY E…
比如音响的音量旋钮
具体逻辑:鼠标按下时期间每帧记录鼠标位置,算出由2D物体中心到鼠标的向量角度,根据角度变化相等地调节2D物体的旋转。
缺点:无法记录拖拽转了几圈
代码:
using UnityEngine;
using UnityEngine…
unity 实现单击物体让其显示或隐藏,再次单击显示或隐藏
using System.Collections; using System.Collections.Generic; using Unity.Burst.CompilerServices; using UnityEngine; using UnityEngine.EventSystems;
public class ToggleObjects : MonoBehaviour {…
1、下载ML-Agents
下载地址
GitHub - Unity-Technologies/ml-agents: The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinfo…
// 本脚本用于演示Component类 方法 //任何一个组件 都可以从游戏物体获取或者从其父对象哪里 子对象哪里获取,一个组件也可以拿到同一个物体上的其他组件 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Component…
一、GB2312和UTF8简介 GB2312(全称:中国国家标准GB2312-80字符集)和UTF-8(全称:Unicode Transformation Format 8-bit)是两种常见的字符编码方案。它们分别用于对文本进行编码,以在计算机系统和…
实现好用的模糊效果_Blur HDRP渲染管线下搭建场景创建RenderTextureRenderTexture 与相机的配置:UI层 Canvas的不同Render Mode:Canvas 在Screen Space - Overlay 模式下:UI旋转Y轴,没有透视。切换到Screen Space - Camera 模式下:UI层跑到物体后面去了,将Plane Distance…
文章目录 Line Renderer组件添加Line Renderer组件重要属性Positions(位置)Width (宽度)Material(材质)其他属性 使用脚本绘制直线绳子运行结果其他文章 Line Renderer组件
我们可以使用LineRenderer组件来…
1.在场景中新建两个 Cube 立方体,在 Scene 视图中将两个 Cude的位置错开。 2.新建 C# 脚本 Distance.cs(写完记得保存)
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Distance : MonoBehav…
1. 用于将世界坐标系转换为屏幕坐标系
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Camer_Class_WorldTo : MonoBehaviour
{// 用于将世界坐标系转换为屏幕坐标系//本脚本将完成一个案例实现 小球从远处过来Transform Sta…
201. 第三轮循环:引入变量
在这一篇,我们进行第三轮 编辑-测试 循环。
在之前我们编写了 输出 Hello Unity 的脚本,如下:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class FirstGameObject …
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;/// <summary>切换对象显示</summary>
public class SwitchObject : MonoBehaviour
{public GameObject[] goList;public Button nextButton;public Button…
文章目录 📕教程说明📕玩家物体配置 Hand Grab Interactor⭐添加 Hand Grab Interactor 物体⭐激活 Hand Grab Visual 和 Hand Grab Glow⭐更新 Best Hover Interactor Group 📕配置可抓取物体(无抓取手势)⭐刚体和碰撞…
第二步:加载AB包的资源,用于显示
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.U2D;
using UnityEngine.UI;public class GameLaunch : MonoBe…
常见的游戏机制
Actor机关门 创建一个Actor类,添加两个静态网格与一个触发器 UBoxComponentUStaticMeshComponent 头文件: #include “Components/BoxComponent.h”#include “Components/StaticMeshComponent.h”
TriggerDoor.h
// Fill out your …
编辑器功能 AddComponentMenu-添加组件菜单
将脚本添加到Unity编辑器的菜单中,方便开发者在编辑器中快速添加组件。
示例
using UnityEngine;
[AddComponentMenu("添加组件/FollowTransform")]
public class FollowTransform : MonoBehaviour
{
}效果 …
2D的射线检测 ,注:目标必须有2d刚体和2d碰撞器 ,且项目设置内必须是这个物理系统 //起点位置let objs new Vec2(this.node.getWorldPosition().x, this.node.getWorldPosition().y);// 终点 let obje new Vec2(objs.x 100, objs.y);// 射线检测let results PhysicsSystem2…
Unity 3D GridLayoutGroup3D 让子物体对齐,调整子物体间距
效果 介绍
GridLayoutGroup3D 脚本是一个用于在 Unity 3D 编辑器中创建 3D 网格布局的实用工具。主要用于在 Unity 编辑器中提供一种可视化的方式来设置和调整子物体的位置,同时支持删除脚本时…
1、添加Img
create->ui->img 把图片拖进去
2、和分数一样、调整位置 3、修改角色脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Fly : MonoBehaviour
{//获取小鸟(刚体)private Rigidbod…
脚本1 触发器脚本 这个脚本是主角身上的脚本,用于检测是否碰到其他触发器,并做出对应的行为 using System.Collections; using System.Collections.Generic; using UnityEngine; public class ColliidisonTrigger : MonoBehaviour { //触发检测 …
Unity_ET-TimerComponent
源码:
namespace ETModel
{public struct Timer{public long Id { get; set; }public long Time { get; set; }public TaskCompletionSource<bool> tcs;}[ObjectSystem]public class TimerComponentUpdateSystem : UpdateSystem<…
【背景】
上一篇讲了如何实现运行Unity程序开启某项服务的需求,那么退出Unity时自然就有需求关闭此服务。
【方法】
假设服务是通过某个exe驱动的,在某个Game Object上追加如下代码:
using UnityEngine;
using System.Diagnostics;public class ExitWithCMDCommand : Mo…
文章目录 前言一、什么是齐次坐标二、齐次坐标增加分量 w 的意义1、当 w ≠ \neq 0时:2、当 w 0时:3、用方程组,直观的看一下w的意义 前言
在之前的文章中,我们进行了正交相机视图空间转化到裁剪空间的推导。
Unity中Shade…
前言
在Unity开发中,会出现一些报错,这次总结一下本人在开发中的常见错误,并跟随其解决方案,以便之后好进行回顾。
编译错误
1.1 错误信息:“The type or namespace name ‘XXX’ could not be found (are you miss…
1.相机跟随组件,节点: 2.相机跟随组件脚本: using System;
using System.Collections;
using System.Collections.Generic;
using Unity.Burst.Intrinsics;
using UnityEngine;
using UnityEngine.UI;public class CameraFollow : Singleton&…
Mesa简介-CSDN博客 Mesa, also called Mesa3D and The Mesa 3D Graphics Library, is an open source software implementation of OpenGL, Vulkan, and other graphics API specifications. Mesa translates these specifications to vendor-specific graphics ha…
项目文件 链接:https://pan.baidu.com/s/1BabHvQ-y0kX_w15r7UvIGQ 提取码:emsg –来自百度网盘超级会员V6的分享
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Mono.Data.Sqlite;
using System;
using Syste…
配置连接点 材质 连接器控制
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Connector : MonoBehaviour
{[Header("连接器位置")]public ConnectorPosition connectorPosition;[Header("连接器所属建筑类型&qu…
1.创建数据库模型
这个是让我们把生活中类似圆柱体和圆锥体的物体进行AR识别所选择的模型 Bottom Diameter:底部直径 Top Diameter:顶部直径
Side Length:圆柱侧面长度
请注意,您不必上传所有三个部分的图片,但您需要先为侧面曲面关联一个图像&#…
本文介绍three.js 中shader的创建和应用到模型,具体shader的语法和函数应用,已经有很多大佬总结过了。 three.js shader详解
import * as THREE from three;const scene new THREE.Scene();//创建场景
scene.backgroundnew THREE.Color(0,0.1,0.2,1);/…
文章目录 前言一、原理1、法一:使用立方体纹理 CubeMap,作为反射纹理使用2、法二:使用反射探针生成环境反射图,所谓反射的采样纹理 二、实现水面反射1、定义和申明CubeMap2、反射向量需要什么3、计算 N ⃗ \vec{N} N 4、计算 V ⃗…
组件Character Controller 中文角色控制器
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class player : MonoBehaviour
{private CharacterController player;void Start(){player GetComponent<CharacterController>();}v…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Sword_Skill_Controller.cs
using System.Collections;
using System.Colle…
想要批量化替换项目预制体资源中Text组件引用的Font字体文件,可以采用以下步骤。
1、在项目的Editor文件中,新建一个名为FontToolEditor的C#脚本文件,然后把以下代码复制粘贴到新建的FontToolEditor的C#脚本文件中。
using System.Collect…
原:基于C#WPF编写的调用讯飞星火大模型工具_c#xf$xccx-CSDN博客
记录一下以防以后用到。
using Newtonsoft.Json;
using System.Collections.Generic;public class JsonResponse
{[JsonProperty("header")]public ResponseHeader Header { get; set; }[…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
Enemy.cs
using System.Collections;
using System.Collections.Generic;
…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
PlayerManager.cs
using System.Collections;
using System.Collections.G…
计时器、模型对象平移函数、枚举定义的使用 对应unity中的一些常用功能
import * as THREE from three;const scene new THREE.Scene();
const camera new THREE.PerspectiveCamera(60, window.innerWidth / window.innerHeight, 0.1, 1000);const renderer new THREE.WebG…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
Sword_Skill_Controller.cs
using System.Collections;
using System.Colle…
在Unity工程任意Editor文件夹下创建C#脚本:CustomAssetHandler
using UnityEngine;
using UnityEditor;
using UnityEditor.Callbacks;public class CustomAssetHandler
{[OnOpenAssetAttribute(1)]public static bool step1(int instanceID, int line){string pat…
using System.Collections; using System.Collections.Generic; using UnityEngine;
public class ModelControl : MonoBehaviour {//障碍物 public List m_obstacle; //右报警线 public GameObject objWarningRight; //实例化 public static ModelControl instance; private …
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
SkillManager.cs
using System.Collections;
using System.Collections.G…
JavaScript 0基础,只是照着官方文档临摹了下,之后有时间再进行细节学习和功能封装。
import * as THREE from three; //引入threejsconst renderer new THREE.WebGLRenderer();//创建渲染器
//设置渲染范围,当前撑满全屏,屏幕左上角是&…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
CharacterStats.cs
using System.Collections;
using System.Collections…
角色控制器组件,当然是将组件放在角色上了。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class c1 : MonoBehaviour
{// 获取角色控制器private CharacterController player;void Start(){// 加载角色控制器player …
1.首先建立一个画布和空对象 2.创建脚本并将代码复制进去
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class suijishu : MonoBehaviour
{public TextMeshProUGUI sjs;void Update(){if (Input.GetKeyDown(KeyCode.…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
PlayerStat
using System.Collections;
using System.Collections.Generi…
目录
1. Playables API
1.1 Playable vs Animation
1.2 Advantages of using the Playables API
1.3 PlayableGraph Visualizer
2. Creating models outside of Unity
2.1 Preparing your model files for export
2.1.1 Scaling factors
2.1.2 优化模型文…
介绍
unity,如何让人物随着鼠标滑动而转向? 方法
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;public class PlayerMovement : MonoBehaviour
{public float speed 6f; …
切图片的代码实现 一般可能需要切帧动画这种, 但个人用,只是刚好需要切个别图 (最好其实是利用同一个贴图,不同的渲染,可以达到图集共用,减少texture实例,但就只是简单用用,就这样) static public Texture2D DePackTexture(Texture2D tex,int x, int y, int width, in…
最近老师扔了个老SDK让我编译成安卓APK,自己的电脑已经是一锅大杂烩了,unity2017,unity2020,Android Studio 3.4.3新老版本全给安上了,最后也是没给编译出来,还是用了老师给的电脑(绿色无污染&a…
参考文章:Unity着色器介绍
Shader基础
Properties
声明格式
[optional: attribute] name(“display text in Inspector”, type name) default value
属性类型
Color:颜色属性,表示 RGBA 颜色值。Range:范围属性,表示一个在…
本文为Google Translate英译中结果,DrGraph在此基础上加了一些校正。英文原版页面:
Listening to player input — Godot Engine (stable) documentation in English
监听玩家输入
在上一课创建您的第一个脚本的基础上,让我们看看任何游戏…
开启雾
window->Rendering->Lighting->Environment Fog Color:雾的颜色。Fog Mode:雾效的模式Fog Density:雾效的浓度,取值范围0~1,数值越大雾效浓度越高。。Linear Fog Start:线性雾效开始距离&…
准备
ISerializationCallbackReceiver接口官方解释和示例 示例中的OnBeforeSerialize()持续调用,OnAfterDeserialize()数据改动调用
Unity中手动配置数据,自动转换为字典数据
using System;
using System.Collections.Generic;
using UnityEngine;
[S…
本文为Google Translate英译中结果,DrGraph在此基础上加了一些校正。英文原版页面:
Creating your first script — Godot Engine (stable) documentation in English
创建你的第一个脚本
在本课中,您将编写您的第一个脚本,使用…
本文为Google Translate英译中结果,DrGraph在此基础上加了一些校正。英文原版页面:
Scripting languages — Godot Engine (stable) documentation in English
脚本语言
本课将概述 Godot 中可用的脚本语言。您将了解每个选项的优缺点。在下一部分中&…
如代码所示,简单了解一下。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class test : MonoBehaviour
{ void Awake(){Debug.Log("awake hello world!");}// 当脚本可用时,也就是打勾的时候可以…
概述
功能:显示视频进度;改变视频进度。
获取 进度条的拖动状态
脚本挂载到进度条对象上
using UnityEngine;
using UnityEngine.EventSystems;
public class SliderControl : MonoBehaviour, IDragHandler, IEndDragHandler, IBeginDragHandler
{//…
你想让鼠标点击哪里,你的运动的对象就运动到哪里吗?
Please follow me !
首先,你要先添加一个Plane ,以及你的围墙,你的移动的物体 想要实现跟随鼠标移动,我们先创建一个脚本
using System.Collections;
using Syst…
文章目录 Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三)前情提要客户端部分 Unity进阶–通过PhotonServer实现联网登录注册功能(客户端)–PhotonServer(三)
前情提要 单例泛型类 using System.Collections;
using System.Collections.Generic;
…
文章目录 publicprivate默认情况的成员变量 public
当在Unity中使用public修饰符时,它将变量声明为公共变量,这意味着该变量可以在Unity编辑器中进行设置,并且可以从其他脚本中访问和修改。公共变量在Unity中广泛用于在脚本之间共享数据&…
今天瑞云渲染小编给大家带来了关于电影制片人Tiziano Fioriti展示了《H I M I L》项目背后的工作流程,解释了人工智能是如何用于细节的,并谈到了设置火光的问题。 介绍
大家好,我叫Tiziano Fioriti,是来自意大利的自由电影制作人…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//*****************************************
//创建人: xxxx
//功能说明:
//***************************************** #ROOTNAMESPACEBEGIN#
public class #SCRI…
对Unity5.x后的AssetBundle依赖机制有了一点理解,创建了一个项目验证 github:GeWenL / AssetBundlePro AbScene.unity
资源有哪些? Some common types of Asset
assetbundle打包命令是 BuildPipeline.BuildAssetBundles ,格式有:
引用&…
文章目录 🟥 UMA Data DNA参数引用位置🟥 UMA API介绍🟥 UMA Data DNA参数引用位置
我们想通过代码去控制如图所示参数,达到捏脸的目的.下面就是可以控制的代码:
_dna["headSize"].Set(1);
_avatar.BuildCharacter();我们观察发现操控代码类似Material去设置…
var dy_btn Button.new()add_child(dy_btn)print(get_child(0).name) 此时获取的名词会带有动态类型,如果这个时候想通过特定的节点名词来获取节点是不行的
此时需要补充类似
dy_btn.name "a"
的代码,然后就能按照节点名词获取节点了
using System; using System.Collections; using System.Collections.Generic; using System.Runtime.InteropServices; using UnityEngine;
public class chuantou : MonoBehaviour { [DllImport(“user32.dll”)] public static extern int MessageBox(IntPtr hwnd,string t…
linerender的标记参考
unity linerenderer在Game窗口中任意画线_游戏内编辑linerender-CSDN博客 让生成的标记转化为ARMarks游戏对象的子物体
LineMark.cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class LineMark : MonoBeh…
定义ScriptableObject资源原型:
public class MConfigObject : ScriptableObject
{public int A;public string B;public MStruct MStruct;
}
动态生成asset资源 var asset ScriptableObject.CreateInstance<MConfigObject >();asset.A 1;AssetDatabase.C…
AgentRadius:烘焙路径可行区域和非可行区域的间隔 AgentHeight:烘焙路劲时当高度小于这个值的地方,就是不可行区域 Max Slope:最大可行区域的坡度 Step Height:最大台阶高度 Drop Helght:下路高度 Jump Dis…
移动对象和父对象的锚点,轴心点为(0.5,0.5)使用IDragHandler, IPointerDownHandler接口RectTransformUtility.ScreenPointToLocalPointInRectangle 屏幕点转换为对应recttransform下的本地位置
using UnityEngine;
using UnityEngine.EventSystems;public class Dr…
动态修改材质自发光
新建一个场景,关闭方向光;目的:自发光更明显创建2个立方体;创建一个材质;材质赋值给新建的两个立方体;两个立方体挂载脚本。
using System.Collections;
using System.Collections.Ge…
分组
一个组包裹着其他控件,组是它们的父物体; 改变父物体的位置,子物体的位置改变
public Rect rect new Rect(0, 0, 100, 50);
private void OnGUI()
{GUI.BeginGroup(rect);GUI.Box(new Rect(0, 0, 50, 50), "子对象1");GUI.…
Unity向量的点乘用于判断怪物相对于人物的方向 using System.Collections; using System.Collections.Generic; using UnityEngine; public class Vector3_Class_methods : MonoBehaviour { // 用于演示Vector3的函数 Vector3 Apoint; Vector3 Bpoint; Vector3 Cpoint; public …
序
抽象的图纸叫类,包含具体数据的叫对象。
类的序列化和反序列化
using System.Collections;
using System.Collections.Generic;
using UnityEngine;using System;
using System.IO;
using System.Runtime.Serialization.Formatters.Binary; [Serializabl…
using System;
using System.IO;
using UnityEditor;
using UnityEditor.ShortcutManagement;
using UnityEngine;/// <summary>
/// 截屏工具类
/// </summary>
public static class ScreenshotUtilities
{[Shortcut("MT_Tools/Take Screenshot 1x", Ke…
Profiler的主要参数详解
1. Memory Profiler Uesd Total : 当前帧的Unity内存,Mono内存,GfxDriver内存,Profiler内存以及额外内存的总和。 Reserved Total: 系统在当前帧申请的总体物理内存 Total System Memory Usage࿱…
/黑屏淡入淡出///using System.Collections;
using UnityEngine;
using UnityEngine.UI;public class MyFadeInOut : MonoBehaviour
{public Image fadeImage;[Tooltip("过渡颜色")]public Color fadeColor Color.black;[Range(1, 100), Tooltip("淡入淡出的速…
实现了支持泛型的优先队列,解决Unity官方不提供优先队列的问题。
API
属性和字段解释size队列的长度capacity队列的容量IsEmpty返回队列是否为空Top返回队列第一个元素
枚举解释PriorityQueueMode.less最小优先队列PriorityQueueMode.equal只会将相等的排在一起P…
using UnityEngine;
using System.IO;
// using System.Xml.Serialization;
public class SaveCoordinates : MonoBehaviour
{public GameObject MainObject;//读取坐标private float x;private float y;private float z;private Quaternion quaternion;private void Start(){/…
项目中需要实现点击“”按钮展开对应分类下的所有训练科目,再次点击“–”按钮将对应分类下的训练科目隐藏并收起整个面板。对此,编写一个类,将其挂载到树形结构的父类上,代码如下:
using UnityEngine;
using UnityEn…
Unity中,我们给Color的赋值比较常用的方法是:
1、使用预定义颜色常量:
Color color Color.white; //白色
Color color Color.black; //黑色
Color color Color.red; //红色
Color color Color.green; //绿色
Color color Color.blue; …
Unity Text超框 文字滚动循环显示 //container Text using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.UI;public class AutoScrollText : MonoBehaviour
{private Text[] _texts new Text[…
首先需要去官方下载Appsflyer的UnityPackage
链接在这afPackage
然后导入
导入完成
引入此段代码
using AppsFlyerSDK;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class AppflysManager : MonoBehaviour
{public static App…
Unity设置:
打开Unity项目。创建一个空的GameObject,并附加一个新的脚本TCPReceiver using System.Net;
using System.Net.Sockets;
using System.Text;
using UnityEngine;
using System.Threading;public class MyListener : MonoBehaviour
{Thread thread;pub…
1.在角色对象上挂在animator组件,并将动作控制器与其关联 2.在角色对象上挂在audio source组件。 3.新建voice control脚本,编写代码如下:
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;…
项目里有代码专门监听网络环境的变化,特别是在下载中,如果遇到断网或者切换为移动网络,可能需要触发提醒等等。这种需求可能是通用的,于是便写了一个通用的监听代码。是
using System;
using System.Collections;
using System.C…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Sword_Skill.cs
using System;
using System.Collections;
using System.C…
场景切换前必须要将场景拖动到Build中 同步加载场景
using System.Collections;
using System.Collections.Generic;
//using UnityEditor.SearchService;
using UnityEngine;
// 场景管理 需要导入该类
using UnityEngine.SceneManagement;public class c3 : MonoBehaviour
{…
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class c2 : MonoBehaviour
{// 定时器float t1 0;void Start(){// 向量Vector3 v1 new Vector3(0, 0, 2);Vector3 v2 new Vector3(0, 0, 3);// 计算两个向量的夹角Debug.Log(Vector3…
文章目录 📕教程说明📕Scene API 实现遮挡📕Scene API 实现遮挡的缺点📕Depth API 实现遮挡⭐导入 Depth API⭐修改环境配置⭐添加 EnvironmentDepthOcclusion 预制体⭐给物体替换遮挡 Shader⭐取消现实手部的遮挡效果 此教程相关…
使用URP之后,Unity报错:显示不正常 NullReferenceException: Object reference not set to an instance of an object UnityEngine.Rendering.Universal.UniversalAdditionalCameraData.get_cameraStack () (at Library/PackageCache/com.unity.render-p…
简单的ui基类
UIBasePanel.cs
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.EventSystems;
using System.Collections.Generic;namespace MYTOOL.UI
{public class UIBasePanel : MonoBehaviour{//通过里式转换原则 来存储所有的控件private readonly Dictio…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
Entity.cs
using System.Collections;
using System.Collections.Generic;…
一 Button的点击
1.1 新建UI -> Button 1.2 在Button上面右击添加空物体 1.3 创建脚本挂载到空物体上面 脚本内容添加点击方法,来控制物体的显示隐藏
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using Unit…
1.键盘、鼠标操作
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.UI;public class NewInputSystem : MonoBehaviour
{public float SpaceKeyValue;public float RightMouseValue;public…
使用Unity编辑器扩展技术实现快速截图功能
效果:
里面没有什么太难的技术,直接上源码吧
注意!代码需要放在Editor文件下才能正常运行
using System;
using UnityEditor;
using UnityEngine;[ExecuteInEditMode]
public class Screenshot …
Unity的由来:
Unity 是一款跨平台的游戏引擎,由 Unity Technologies 公司开发和维护。Unity 的起源可以追溯到 2002 年,当时 Unity Technologies 创始人之一的 David Helgason 在丹麦创建了一个名为 Over the Edge Entertainment 的游戏开发…
1.在Unity场景中新建一个空物体,在空物体上添加MeshRenderer和MeshFilter组件。
2.新建一个C#脚本命名SphereMesh,将脚本挂载到空物体上,如图: 运行场景就可以看到生成一个球体 全部代码如下:
using UnityEngine;public class S…
Unity AI Sentis基础教程 Unity AI Sentis基础教程Unity AI 内测资格申请Unity 项目Package Manager开始尝试模型下载识别图片完整代码代码搭载运行 射线绘画 URP(扩展)射线绘画脚本脚本搭载效果 Sentis 是 AI 模型的本地推理引擎,它利用最终…
当前测试使用的Entities版本为1.0.16
Unity Entities 1.0.16使用方法:
Create a component for the spawner example | Entities | 1.0.16
1. 创建SubScene 2. 在SubScene下创建挂载Authoring脚本:
Authoring是MonoBehaviour脚本,主要用来…
添加天天气组件unistorm 然后添加一个player
导入包会报错,需要修改代码
using UnityEngine;
using UnityEngine.PostProcessing;namespace UnityEditor.PostProcessing
{[CustomPropertyDrawer(typeof(UnityEngine.PostProcessing.MinAttribute))]sealed class MinDrawer : …
201. 第三轮循环:引入变量
在这一篇,我们进行第三轮 编辑-测试 循环。
在之前我们编写了 输出 Hello Godot 的脚本,如下:
extends Node# Called when the node enters the scene tree for the first time.
func _ready():print("Hell…
vs Code因为免费启动(飓快)的原因,已经成为事实的第一首选的IDE了
比sublime还快很多很多,其他特性包括但不限于:
最直接的github拉取,提交管理插件管理支持各种语言的识别代码分屏 是毫无疑问的第一编程…
在任意的脚本组件中(必须先绑定物体),添加一个公开的 GameObject 类型的变量
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class test1 : MonoBehaviour
{public GameObject other;// Start is …
从Assets开始路径要写全,需要.unity扩展名
如果路径写错了会报错
LoadSceneAsyncInPlayMode expects a valid full path. The provided path was Assets/Works/Resource/Scenes.unity
string sceneFullPath "Assets/Works/Resource/Scenes/TestScene.unity…
1.场景加载 cc.director.loadScene(场景名称);//场景跳转 cc.director.preloadScene(场景名称);//预加载场景
cc.director.getScene();//获取当前场景
2.获取节点 var node cc.find("Canvas/bg");//通过访问路径来获取节点
var a this.node.getChildByName(name…
如何使用 只需在“项目”窗口中创建一个名为“编辑器”的文件夹,然后在其中添加此脚本即可。然后,打开窗口-Convert Textures to PNG,配置参数并点击“Convert to PNG! ”。
就我而言,它已将某些 3D 资源的总文件大小…
unity 3d
Unity是一个游戏引擎,包含渲染引擎,物理引擎,碰撞检测,音效,动画效果,场景管理等系统。它的开发效率高、脚本使用C#开发、简单易用、跨平台(可以导出各个平台的程序)&…
在Unity中,Lerp()方法用于在两个值之间进行线性插值。
它的语法有:
public static float Lerp(float a, float b, float t);//在两个float类型的值a和b之间进行线性插值
public static Vector2 Lerp(Vector2 a, Vector2 b, float t);//在两个Vector2类…
需求: 如果LayoutGroup的子物体太多,超出layoutGroup的范围,则对子物体进行缩小。确保子物体都在LayoutGroup的范围内 代码: [ExecuteInEditMode]
[RequireComponent(typeof(HorizontalOrVerticalLayoutGroup))]
public class Lay…
Unity版本:2018.4.0f1
上代码,直接挂载到空的游戏物体身上
using System;
using UnityEngine;
using UnityEngine.UI;namespace UnityStandardAssets.Utility
{[RequireComponent(typeof (Text))]public class FPSCounter : MonoBehaviour{const float…
首先,下载一个shapes插件!
为shapes插件的立刻绘画模式创建一个脚本
using Shapes;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Rendering;namespace XXX
{[ExecuteAlways]public class Draw…
在设置子物体的父物体时,我们使用SetParent再常见不过了。
但是通常我们只是使用其中一个语法:
public void SetParent(Transform parent);使用改方法子对象会保持原来位置,跟使用以下方法效果一样:
public Transform tran;
ga…
写 Unity Shader的时候,只有播放状态下的 Game 面板能看到Shader 顺畅的动态效果,不方便。 想要带有动态效果的 Shader 在 Scene 面板持续更新动画,只需要打开一个开关就能让 Scene 持续刷新动画了。 感谢大家的观看,您的点赞和关…
1、素材包获取
链接: https://pan.baidu.com/s/1KgCtQ_7wt2mlbGbIaMVvmw 提取码: xxh8
2、将素材全部拉进去 3、创建新的场景 并且将场景添加到build settings里面
4、脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityE…
新建c#脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Fly : MonoBehaviour
{//获取小鸟(刚体)private Rigidbody2D bird;//速度public float speed;// Start is called before the first frame up…
代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using System;
using System.Runtime.InteropServices;
public class MyWindow : MonoBehaviour
{[DllImport("user32.dll")]private static extern IntPtr GetActiveWindow(…
1、切换到动画器 点击make transition和exit关联起来
2、设置参数 勾选掉Has Exit Time
3、脚本给动画器传参
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class Fly : MonoBehaviour
{//获取小鸟(刚体)p…
/// <summary> /// 针对相机的截图 /// </summary> public void CameraScreenShot(){ Rect rect new Rect(0,0,Screen.width,Screen.height); RenderTexture renderTexture RenderTexture.GetTemporary((int)rect.width,(int)rect.height,0, RenderTextureFormat…
ZXing 创建及识别二维码
生成二维码
目标
能够生成任意大小的二维码生成的二维码可调整背景颜色和码点的颜色生成的二维码中心可带有小Icon生成的二维码可带边框并可调整边框宽度和颜色
实现
using System.Collections.Generic;
using UnityEngine;
using ZXing;
using ZX…
文章目录 前言一、实现菲涅尔效果1、求 N ⃗ \vec{N} N 2、求 V ⃗ \vec{V} V 3、得出菲涅尔效果4、得出菲涅尔相反效果5、增加菲涅尔颜色二、能量罩 交接处高亮 和 外发光效果结合1、修改混合模式,使能量罩透明2、限制 0 ≤ H i g h L i g h t C o l o r ≤ 1 0\leq HighL…
目录 Widget是什么
Widget组件包含的属性
Pivot
Depth
Size
snap
Aspect
Free
Based on Width
Based on Height Widget是什么
在Unity UI系统中,"Widget"是指UI元素的基类,它为UI元素提供了位置、大小和锚点等基本属性。通过使用&qu…
在新手引导每一步中实现可以遮掉其他部分而显示当前需要点击的部分,只需要在每一步引导的时候设置对应的镂空区域的RectTransform.效果如下图: 代码:
public class SelfMaskSet : MaskableGraphic, ICanvasRaycastFilter
{[SerializeField]p…
代码获取组件
using System;
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;// 必须要继承 MonoBehaviour 才是一个组件
// 类名必要与文件名一致public class c1 : MonoBehaviour
{// 使用 public 初始变量时…
在Unity中,万物皆是由组件构成的。 右键创建C#脚本,拖动脚本到某物体的组件列表。
生命周期相关函数
using System.Collections;
using System.Collections.Generic;
using UnityEngine;// 必须要继承 MonoBehaviour 才是一个组件
// 类名…
文章目录 示例1:游戏事件处理系统示例2:UI消息处理链示例3:游戏内物理碰撞响应链示例4:AI决策链示例5:场景切换责任链示例6:输入命令处理链 责任链模式(Chain of Responsibility)在U…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
Sword_Skill.cs
using System.Collections;
using System.Collections.Ge…
创建BMPLoader.cs
此方法是用来将数据流解析成texture,BMP数据流不同于其他图片数据,所以需要特殊处理
#region License and Information
/*****
*
* BMPLoader.cs
*
* This is a simple implementation of a BMP file loader for Unity3D.
* Formats…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Entity.cs
using System.Collections;
using System.Collections.Generic;
u…
1建立文本组件和一个空对象 2创建一个脚本并复制下面代码
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;public class showtime: MonoBehaviour
{public TextMeshProUGUI time;private void Update(){string currentTime Sy…
public class showtime : MonoBehaviour
{public TextMeshProUGUI Countdown;void Update(){if (Input.GetKeyDown(KeyCode.Space))//如果按下空格后开始倒计时{StartCoroutine(hahaha());}}IEnumerator hahaha()//声明了一个协程函数 hahaha{int time 10;Countdown.text tim…
// 导入必要的命名空间
using System.Collections;
using System.Collections.Generic;
using UnityEngine;// 创建一个名为 RotateObj 的 MonoBehaviour 类,该类可以附加到 Unity 中的游戏对象上并控制其行为
public class RotateObj : MonoBehaviour
{// Update 函…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili EnemyStat.cs
using System.Collections;
using System.Collections.Gener…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili ItemData_Equipment.cs
using System.Collections;
using System.Collecti…
在Unity中,TrailRenderer组件用于在对象移动时创建轨迹效果。通常用于增强游戏中的动态物体,比如子弹、飞行道具或者角色移动时的拖尾效果。
下面来了解下它的基本信息。
1、创建
法1:通过代码创建
using UnityEngine;public class Trail…
背包系统脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.XR.Interaction.Toolkit;
using UnityEngine.InputSystem;public class 背包系统背包 : MonoBehaviour
{public GameObject 左手手柄; // 左手控制器public …
导入unity中的代码,出现如下错误,该如何解决? Unsafe code may only appear if compiling with /unsafe. Enable "Allow unsafe code" in Player Settings to fix this error 解决这个问题,只需要设置就可以。
设置的地…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
UI.cs
using System.Collections;
using System.Collections.Generic;
usi…
文章目录 什么是协程协程的应用 - IEnumerator如何控制协程的暂停协程的另一种写法 - Invoke场景管理 多看代码块中的注释 什么是协程
A coroutine alows vou to spreacwhere it left off on the following anc return control toolinencoeframe. 协程允许您将任务分布在多个帧…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
CharacterStats.cs
using System.Collections;
using System.Collections…
关键词:UnityWebRequest、Http协议、Get请求、0 bytes received
using Newtonsoft.Json;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Networking;public class MyWebRequest : MonoBehavi…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码、
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Blackhole_Skill_Controller.cs
using System.Collections;
using Syste…
场景搭建
2.按钮播放视频这部分写一个按钮回调函数即可 3.控制视频的代码
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Video;public class videomanager : MonoBehaviour
{// 这个脚本实现按钮控制VIDEO播放GameO…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Stat.cs
using System.Collections;
using System.Collections.Generic;
us…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
Clone_Skill.cs
using System.Collections;
using System.Collections.Ge…
一、Player Settings 设置 Player Settings>Player>Other Settings> Android > Write Permission > External (SDCard). 二、代码
using System.Collections;
using System.Collections.Generic;
using System.IO;
using UnityEngine;
using UnityEngine.Andr…
Dylan Chua 和 Anne Lee 开发了一个处理管线,用于对 3D Tiles 中包含的 GL 传输格式 (glTF) 模型进行语义分割。 该管道读取并遍历 3D Tileset,以输出包含元数据的经过转换的划分对象集。 该项目为 3D 语义分割器提供了最小可行产品,作为各种…
要实现InputField框自适应输入内容,除了通过代码进行处理,还可以是使用以下简便的方法。
1、创建InputField组件:右键->UI->Input Field -TextMeshPro。
2、把Input Field Settings中的Line Type设置为Multi Line Newline模式&#x…
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using UnityEditor;
using UnityEngine;
using UnityEngine.UI;/// <summary>
/// 模板脚本生成
/// </summary>
public class ScriptCreater : EditorW…
下载素材: 导入后,找到预制体和动画。 新建动画控制器,拖动到预制体的新版动画组件上。 建立动画关系 创建脚本,挂载到预制体上。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public c…
制作好站立和移动的动画后
控制器设计 站立
移动
角色移动代码如下:
using System.Collections;
using System.Collections.Generic;
using Unity.VisualScripting;
using UnityEngine;public class p1_c : MonoBehaviour
{// 获取动画组件private Animator …
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili ItemObject_Trigger.cs
using System.Collections;
using System.Collecti…
作者简介: 高科,先后在 IBM PlatformComputing从事网格计算,淘米网,网易从事游戏服务器开发,拥有丰富的C++,go等语言开发经验,mysql,mongo,redis等数据库,设计模式和网络库开发经验,对战棋类,回合制,moba类页游,手游有丰富的架构设计和开发经验。 (谢谢你的关注…
Exception堆栈追踪
上代码
try{SaveData saveData SaveLoadManager.Load(migrate: false);if (saveData ! null){Version v new Version(saveData.gameVersion);Version v2 new Version(Cheats.version);if (v < v2){SaveLoadManager.MigrationBackupLocalSave();SaveL…
一、插值
线性插值是采用一次多项式上进行的插值计算,任意给定两个值A和B,那么在A和B之间的任意值可以定义为:P(t) A * (1 - t) B * t,0 < t < 1。 数学中用于线性拟合,游戏应用可以做出跟随效果(…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili UI_CraftList.cs
using System.Collections;
using System.Collections.Gen…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili Inventory.cs
using Newtonsoft.Json.Linq;
using System.Collections;
us…
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class FollowPathMove : MonoBehaviour
{public Transform[] wayPointArray;[SerializeField] private Transform PathA;//路径点的父物体[SerializeField]private Trans…
引用传递
//引用传递
static void SetY(out int x,out int y ){x 0;y 0;x 1000;}static void Main(string[] args){int x 0;int y 10;SetY(out x, out y);Console.WriteLine($"x{x},y{y}");}
结果是:x1000,y0
数组的引用传递
数组值…
Unity Pro 2019是一款功能强大的游戏开发引擎,其特点主要体现在以下几个方面:
强大的渲染技术:Unity Pro 2019采用了新的渲染技术,包括脚本化渲染流水线,能够轻松自定义渲染管线,通过C#代码和材料材质&…
项目需求为:
1.实现存档列表,显示存档截图,可以查看之前保存的所有存档
2.点击存档直接加载到场景 首先,定义两个类,用于声明存档列表和存档所需要的List
[System.Serializable]
public class SaveData
{//存储目标…
一、 角色控制器
Character Controller和普通的动态对象(Dynamic Actor )是不同的,主要的三个特点是:
它拥有可控制的刚体间的交互假设它是有无穷的摩擦力(可以站停在位置上),没有弹性加速和刹车几乎立即…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
UI_Statslot.cs
using System.Collections;
using System.Collections.Gen…
目录 打包代码前置1.必须要安装Visusal Studio 2022的组件,如下图,必须都要进行安装,不然会在代码重构的时候报错,丢失SDK。Rider的版本必须2023及以上 步骤一、使用Rider编辑器打开项目后进行重构项目步骤二、使用HybirdCLR生成A…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码 【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
UI.cs
using System.Collections;
using System.Collections.Generic;
usi…
shader显示在3D物体前,先转化成视口坐标 public virtual void SetESignPos() { float x 0; float y 0; int v PlayerPrefsTool.GetSpecialScreen(-1); if (EScreenCamera ! null) { Vector3 viewPointEScreenCa…
Alex教程每一P的教程原代码加上我自己的理解初步理解写的注释,可供学习Alex教程的人参考 此代码仅为较上一P有所改变的代码
【Unity教程】从0编程制作类银河恶魔城游戏_哔哩哔哩_bilibili
HealthBar_UI.cs
using System.Collections;
using System.Collections.G…
Aspect Ratio Fitter是Unity中的一种布局控制器组件,用于根据指定的宽高比来调整包含它的UI元素的大小。实际开发中,它可以确保UI元素保持特定的宽高比,无论UI元素的内容或父容器的大小如何变化。
如图为Aspect Ratio Fitter组件的基本属性&…
1.创建3个静态物体摆好位置,并将其图层设为UI 2.编写一个脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;public class xt : MonoBehaviour
{public GameObject xt1;public GameObject xt2;public GameObject xt3;int x 1;…