This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//法线贴图有两种,一种是模型空间的贴图,也就是贴图中的法线信息是在模型空间下的;第二种是切线空间的贴图,也就是贴图中的法线信息是在切线空间下的。 | |
//由于后一种要比前一种好用,所以后面用的皆为切线空间中的法线贴图。 | |
Shader "Unlit/NormalTex" | |
{ | |
Properties | |
{ | |
_MainTex ("Texture", 2D) = "white" {} | |
_MainNormalTex("NormalTex",2D) = "white"{} | |
} | |
SubShader |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//1、采用webrequest下载文件,最终文件下载得到的是一个byte[]数组 | |
IEnumerator GetText() | |
{ | |
using (UnityWebRequest request = UnityWebRequest.Get("localhost:80/txt/test.txt")) | |
{ | |
yield return request.Send(); | |
if (request.isError) | |
{ | |
Debug.Log(request.error); | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//组件有四个属性: | |
// Alpha:透明度 | |
// Interactable:是否禁用输入交互 | |
// Block Raycasts:是否禁用射线检测 | |
// Ignore Parent Groups:是否忽略父级Canvas Group | |
//该组件作用于挂载该组件的GameObject及其子物体。利用这一点,可以控制整个UI窗口的Alpha值,而不必纠结其下有多少子物体,也可以利用该组件设置整个窗口内所有组件的不可点击。 | |
//因为通知内容长度不定,窗口大小和文本框要自动缩放。 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//通过Mesh与PolygonCollider2D的数据转化,完成创建,注释有详细说明: | |
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using UnityEngine; | |
public class AdjustColliderOrMesh : MonoBehaviour | |
{ | |
[SerializeField] bool useMass; | |
[SerializeField] float massCoefficient = 1; | |
[HideInInspector] public Vector3 centerPoint; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//在实时的绘制完成LineRenderer之后,会动态的添加PolygonCollider2D多边形碰撞体。读取LineRenderer的点位(一条折线),左右各便宜一定距离,形成一个闭合的线框,利用线框的点位修改PolygonCollider2D形状。 | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class LineCollider : MonoBehaviour | |
{ | |
//绘制过程中显示用LineRenderer | |
[SerializeField] LineRenderer drawingLine; | |
//带有碰撞体的LineRenderer, 要有PolygonCollider2D、LineRenderer组件, | |
[SerializeField] GameObject colliderLinePrefab; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//像以前玩过的TNT、弹弹岛、百战天虫这样的游戏,都会有一个弹道路线提示,而通过施加力或速度,可以控制刚体移动。 | |
//以下插件(脚本),可以通过刚体信息、速度、受力等信息,计算出刚提的运动轨迹,与刚体实际运动轨迹完全相符(计算方式可能与Unity物理引擎计算方式类似或相同),可以实现预计算弹道轨迹等功能。 | |
//免费插件链接:Calculate Trajectory https://assetstore.unity.com/packages/tools/physics/calculate-trajectory-84341 | |
//下面解析模拟物理计算代码,做了一些修改: | |
public static class RigidbodyExtension | |
{ | |
//returns返回值:运动轨迹点位位置及该点的速度 | |
//stepCount:运动轨迹点位数量,数量越多,得到的轨迹越远,计算量也就越多 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
public class BezierLine : MonoBehaviour | |
{ | |
[SerializeField] LineRenderer lineRenderer; | |
[SerializeField] int bezierPointCount = 10; | |
[SerializeField] List<Vector3> pointList; | |
void Start() | |
{ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//命令模式 | |
//此功能需要用到一种叫做命令模式的设计模式,就是把操作封装成一个命令,通俗易懂地说就是设计一个 Command 类,其中包含 Excute 和 Undo 两个方法。Excute 用于执行此命令,Undo 用于撤销此操作,但 Excute 还有一个功能,就是还可以 Redo 即重做之前 Undo 方法撤销的操作。 | |
//这个 Command 是个基类,具体的命令要继承自它,并重写它的方法。当要执行某个操作的时候,需要编写特定的 XXXCommand 并继承自 Command,然后执行,撤销和重做就是调用其中的 Undo 和 Excute | |
namespace Windsmoon | |
{ | |
public abstract class Command | |
{ | |
#region methods | |
public abstract void Excute(); | |
public abstract void Undo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using System.Linq; | |
using UnityEngine; | |
using UnityEngine.SceneManagement; | |
using UnityEngine.UI; | |
public class PlayerShadow : MonoBehaviour | |
{ | |
// Mesh : 网格, 由三角形面组成 | |
// Mesh Filter : 设置网格信息 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
WAYLAND_PROTOCOLS=/usr/share/wayland-protocols | |
# wayland-scanner is a tool which generates C headers and rigging for Wayland | |
# protocols, which are specified in XML. wlroots requires you to rig these up | |
# to your build system yourself and provide them in the include path. | |
xdg-shell-protocol.h: | |
wayland-scanner server-header \ | |
$(WAYLAND_PROTOCOLS)/stable/xdg-shell/xdg-shell.xml $@ | |
xdg-shell-protocol.c: xdg-shell-protocol.h |