文章目录
一、前言
进行了之前搭建的场景的完善。并学习到了一些游戏代码编写的技巧,编写了相关代码。
二、天空盒子的设置
1.下载并导入资源
在unity asset store中搜索skybox资源,download后在unity中的顶层菜单列表中选择
2.在菜单栏进行设置
可以看到系统默认的天空盒子的材质是Default-Skybox
点击右侧的圆圈形状的按钮,在列表中找到刚才导入的天空盒子并选择,即可实现天空盒子的修改,会比初始的场景更加美观。
同时,在assets面板中选择对应的天空盒子,可以通过inspector窗口调整这个天空盒子的材质。
三、游戏中人物的影子
UniversalRenderPipelineAsset
四、场景的光照设置
找到rendering菜单
点击该菜单,会弹出一个光线设置的面板,在里面就可以对场景光线的相关渲染设置进行调整。
五、unity中的一些技巧
const
const:声明某个常量字段或常量局部变量。
注意:常量字段和常量局部变量不是变量并且不能修改
可以利用const管理游戏标签,例如:
//管理所有标签
public const string PlayerPrefs= "player";
public const string enemys = "enemys";
public const string items = "items";
我们的项目中也使用了一个const脚本进行相应的管理。
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Const
{
#region PlayerPrefs关键字
public const string Account = "Account";
public const string LoginModeNameKey = "loginModeNameKey";
public const string GuestModeNameKey = "guestModeNameKey";
#endregion
/*
public const float ASTEROIDS_MIN_SPAWN_TIME = 5.0f;
public const float ASTEROIDS_MAX_SPAWN_TIME = 10.0f;
public const float PLAYER_RESPAWN_TIME = 4.0f;
*/
#region 游戏、记录参数
public const string ROOM_GAME_TYPE = "RoomGameType";
public const int PLAYER_MAX_LIVES = 1;//最大生命
public const string PLAYER_LIVES = "PlayerLives";
public const string Player_Ready = "IsPlayerReady";
public const string PLAYER_LOADED_LEVEL = "PlayerLoadedLevel";
public const string WIN_COUNT = "WinCount";//没有实现轮换制中记录胜利局数,可以删除//TODO
#endregion
#region 游戏场景名字符串--常量名按顺序命名,值按游戏内容命名。以此记录顺序与内容的匹配。
public const string PUN_FIRST_GAME_NAME = "PunPlatformGameScene1";//platform
public const string PUN_THIRD_GAME_NAME = "PunPveGameScene";//pve
public const string PUN_FORTH_GAME_NAME = "AsteroidsGameScene";//demo
public const string PUN_FIFTH_GAME_NAME = "OnlineMap";//pvp
public const string PUN_PROPS_GAME_NAME = "PropsPVPGame";
public const string PUN_SECOND_GAME_BASENAME = "SecondGame0";//竞速***** thisString + Random.Range(1,3);
public const string PUN_SECOND_GAME_NAME_ONE = "SecondGame01";//竞速-----第二个游戏的第一个场景
public const string PUN_SECOND_GAME_NAME_TWO = "SecondGame02";//竞速-----第二个游戏的第二个场景
#endregion
#region 预制体位置字符串
public const string PUN_PLATFORM_GAME_PLAYER_PREFABS_BASEPATH = "PunPlatformGamePrefabs/PlayerPrefabs/";
public const string PUN_PLATFORM_GAME_PLATFORM_PREFABS_BASEPATH = "PunPlatformGamePrefabs/PlatformPrefabs/";
public const string PUN_PVE_GAME_PREFABS_BASEPATH = "PunPveGamePrefabs/";
public const string PUN_SECONDGAME_PREFABS_BASETH = "PunSecendGamePrefabs/";
public const string PlayerPrefabName = "PunShoot/";
public const string PUN_PROPS_GAME_PREFABS_BASEPATH = "PunPropsGamePrefabs/";
#endregion
#region 哈希表键
//分数在官方已经写好的里面,键是score。class:PunPlayerScores
/*
public const string BEAT_ENEMY_TO_DEATH_SCORE_KEY = "BeatEnemyToDeathScore";//击杀量用原来的score
public const string ENEMY_DAMAGE_SCORE_KEY = "EnemyDamageScore";
public const string PLAYER_DAMAGE_KEY = "PlayerDamage";
*/
#endregion
}