0%

unity中关于相机移动(包括平移和远近缩放)的三个脚本,如果使用的话将它们全部挂载在一个空object上就好,数值等可以参考下图:
1

代码:

CameraMoveDirectionKey.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System.Collections;
using System.Collections.Generic;
using UnityEngine;


/// <summary>
/// 镜头移动方式1:通过wasd(或者上下左右方向键)来上下左右平移镜头
/// </summary>
public class CameraMoveDirectionKey : MonoBehaviour
{
//镜头平移的速率
public float moveSpeed = 100.0f;

//镜头
public Transform camera;





// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
float horizontalInput = Input.GetAxis("Horizontal");
float verticalInput = Input.GetAxis("Vertical");


Vector3 forwardMove = moveSpeed * camera.up * verticalInput * Time.deltaTime;
forwardMove.y = 0;
Vector3 rightMove = moveSpeed * camera.right * horizontalInput * Time.deltaTime;

Vector3 move = forwardMove + rightMove;
camera.position += move;

}
}

CameraScroll.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using System.Collections;
using System.Collections.Generic;
using UnityEngine;



/// <summary>
/// 滑动鼠标滚轮使得镜头竖直上下移动
/// </summary>
public class CameraScroll : MonoBehaviour
{
public float zoomSpeed = 600.0f;

public Transform camera;


// Start is called before the first frame update
void Start()
{

}

// Update is called once per frame
void Update()
{
float scrollInput = -Input.GetAxis("Mouse ScrollWheel");
Vector3 upMove = new Vector3(0, scrollInput * zoomSpeed * Time.deltaTime, 0);
camera.position += upMove;
}
}

CameraMoveMouse.cs

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 鼠标移动到屏幕边缘然后使得镜头移动
/// </summary>
public class CameraMoveMouse : MonoBehaviour
{
public float mouseOffset=0.01f;
public Transform myCamera;
public float moveSpeed=1f;

private float maxY = 1f;
private float maxX = 1f;

private void mouseInScreenBound()
{
Vector3 v1 = Camera.main.ScreenToViewportPoint(Input.mousePosition);
//上移
if (v1.y >= maxY - mouseOffset)
{
myCamera.Translate(Vector2.up * moveSpeed);
}
//下移
if (v1.y <= mouseOffset)
{
myCamera.Translate(Vector2.down * moveSpeed);
}
//左移
if (v1.x <= mouseOffset)
{
myCamera.Translate(Vector2.left * moveSpeed);
}
//右移
if (v1.x >= maxX - mouseOffset)
{
myCamera.Translate(Vector2.right * moveSpeed);
}
}

private void Start()
{

}

private void Update()
{
mouseInScreenBound();
}

}

长期更新。记录一些值得借鉴的游戏工作室或up主/youtuber。

adamvisionstudios

一个人的工作室,兼主程序,兼策划,兼美术。定价低廉(1美元左右)以量取胜,游戏小巧开发快:一款游戏一周以内就开发完成。销量几万份到几十万份。
游戏可以在steam上买到。
介绍:https://www.zhihu.com/question/21527269
工作室网址:http://www.adamvisionstudios.com/

Imphenzia

youtuber,讲解了blender在游戏设计中的使用。
主页:https://www.youtube.com/channel/UCzfWju7SFoWLCyV_gDVCrGA

Dani

youtuber,开发了多人生存游戏Muck并发布在了steam上,94%好评;正在制作karlson,即将发布在steam上。
主页:https://www.youtube.com/channel/UCIabPXjvT5BVTxRDPCBBOOQ
其中有他开发muck的流程,可以借鉴。

这是和TA相关的一块技术,有时间可以学学计算机图形学对这块有帮助。

自己的代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
Shader "Siki/MyShader"
{
Properties//属性
{
_Color("_Color",color)=(1,1,1,1)
_Vector("_Vector",vector)=(1,2,3,4)
_Int("_Int",int) = 2
_Float("_Float",float)=3.0
_Range("_Range",range(1,11)) =6
//_2D("_2D",2D) = "red"()
//_Cube("Cube",Cube) = "white"()
//_3D("3D",3D) = "black"()
}

SubShader//控制效果
{
pass
{
CGPROGRAM

#include "UnityCG.cginc"



fixed4 _Color;//float 2进制32位;half 2进制16位,正负6万;fixed 2进制 -2到+2
float4 _Vector;
float _Int;
float _Float;
float _Range;

//顶点函数,这里只是声明函数名
#pragma vertex vert
//片元函数
#pragma fragment frag

float4 vert(float4 v:POSITION):SV_POSITION
{
//float4 pos = mul(UNITY_MATRIX_MVP,v);
float4 pos = UnityObjectToClipPos(v);
return pos;

}

float4 frag():SV_TARGET0
{
return float4(0.5,0.5,1,1);
}


ENDCG
}
}

FallBack "VertexLit"
}







//以下是标准shader
//Shader "Custom/Shader1"
//{
// Properties
// {
// _Color ("Color", Color) = (1,1,1,1)
// _MainTex ("Albedo (RGB)", 2D) = "white" {}
// _Glossiness ("Smoothness", Range(0,1)) = 0.5
// _Metallic ("Metallic", Range(0,1)) = 0.0
// }
// SubShader
// {
// Tags { "RenderType"="Opaque" }
// LOD 200

// CGPROGRAM
// // Physically based Standard lighting model, and enable shadows on all light types
// #pragma surface surf Standard fullforwardshadows

// // Use shader model 3.0 target, to get nicer looking lighting
// #pragma target 3.0

// sampler2D _MainTex;

// struct Input
// {
// float2 uv_MainTex;
// };

// half _Glossiness;
// half _Metallic;
// fixed4 _Color;

// // Add instancing support for this shader. You need to check 'Enable Instancing' on materials that use the shader.
// // See https://docs.unity3d.com/Manual/GPUInstancing.html for more information about instancing.
// // #pragma instancing_options assumeuniformscaling
// UNITY_INSTANCING_BUFFER_START(Props)
// // put more per-instance properties here
// UNITY_INSTANCING_BUFFER_END(Props)

// void surf (Input IN, inout SurfaceOutputStandard o)
// {
// // Albedo comes from a texture tinted by color
// fixed4 c = tex2D (_MainTex, IN.uv_MainTex) * _Color;
// o.Albedo = c.rgb;
// // Metallic and smoothness come from slider variables
// o.Metallic = _Metallic;
// o.Smoothness = _Glossiness;
// o.Alpha = c.a;
// }
// ENDCG
// }
// FallBack "Diffuse"
//}

siki案例截图

siki课程中的案例:
链接:
https://www.bilibili.com/video/BV1kk4y1R7Lc

siki01
siki02

https://developer.vuforia.com/forum/vumark-design-tools/errors-illustrator-scripts#comment-55448
在将Vumark的三个AI脚本插入到AI中时可能会发生bug提示说:
“Error 1302: No such element

Line 117

此时需要安装3种字体:
MyriadPro-Semibold
MyriadPro-Regular
MyriadPro-Bold
到google直接搜索这三种字体,然后进入fontsgeek这个网站下载,
然后打开“我的电脑(计算机)”,在地址栏输入C:\WINDOWS\Fonts,打开Windows字体文件夹。 复制解压出来的字体文件,粘贴到C:\WINDOWS\Fonts文件夹里。 字体即完成安装。

vscode中一些关于html开发的经验

1.新建html文件然后输入!就会自动弹出如下html语句:

1
2
3
4
5
6
7
8
9
10
11
12
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>

</body>
</html>

然后在“body”标签里写网页主干的代码,在“title”标签里确定网页的标题就好了。
2.ALT+B;或者右键然后选择“open in default browser”就可以在浏览器中浏览当前网页
需要插件:Open in Browser
3.一些有用的插件:
Open in Browser:右击选择浏览器打开html文件
Auto Rename Tag:自动重命名配对的HTML/XML标签
CSS Peek:追踪至样式

常用标签记录

标题

标题从h1到h6;显示上会越来越小;每个标题独占一行。

1
2
3
4
5
6
<h1>标题</h1>
<h2>标题</h2>
<h3>标题</h3>
<h4>标题</h4>
<h5>标题</h5>
<h6>标题</h6>

段落

可以将网页分为若干个段落

1
2
3
<p>第一段</p>
<p>第二段</p>
<p>第三段</p>

换行

强制换行的标签

1
2
3
<p>
这是第一段的文字,其中换行<br />是这么用的
</p>

文本格式化

将文本以更特殊的形式表示。

1
2
3
4
5
6
7
8
9
10
11
<strong>加粗</strong>
<b>加粗</b>

<em>倾斜</em>
<i>倾斜</i>

<del>删除线</del>
<s>删除线</s>

<ins>下划线</ins>
<u>下划线</u>

用来布局的“盒子”

div和span,没有特殊内容,是一个“盒子”,用来布局,用来装其它内容(比如图片)。
div是个“大盒子”,单独占一行。
span是个“小盒子”,一行可以多个。

1
2
3
4
5
<div>我是div标签我单独占一行</div>
<div>我是div标签我单独占一行</div>
<span>百度</span>
<span>新浪</span>
<span>搜狐</span>

图片标签

显示图片的标签。

1
<img src="url" alt = "介绍文字"/>

img对应的属性如下图所示:
img标签的属性

持续更新。记录ros中的rtabmap的使用经验。
在此之前确保kinect2已经配置完毕。

初始运行

https://blog.csdn.net/xmy306538517/article/details/78771018
https://blog.csdn.net/sean_xyz/article/details/65445038

rtabmap的github说明

https://github.com/introlab/rtabmap/wiki/Kinect-mapping

ros上对rtabmap的说明

http://wiki.ros.org/rtabmap_ros/Tutorials/HandHeldMapping

一些问题

如果在建图时图像变红说明此时无法建图,很大可能是相机移动太快导致现在的帧和上一帧匹配不上。
rviz和rtabmap尽量不要一起开,否则rtabmap会很卡。