unity3d

Get mouse position in world space

天大地大妈咪最大 提交于 2021-01-02 01:57:58
问题 I'm making a game using Unity and I have a little issue, I need to know the mouse position in world space, for that I try to set a GameObject at the mouse position using this code : Vector3 p = Input.mousePosition; Vector3 pos = Camera.main.ScreenToWorldPoint( p); testGameObject.transform.position = pos; It works like a charm in Editor but in exe / apk, the GameObject dosn't follow the mouse: Example 1 Example 2 The GameObject that is supposed to follow the mouse is the "1" inside a circle

Get mouse position in world space

橙三吉。 提交于 2021-01-02 01:52:17
问题 I'm making a game using Unity and I have a little issue, I need to know the mouse position in world space, for that I try to set a GameObject at the mouse position using this code : Vector3 p = Input.mousePosition; Vector3 pos = Camera.main.ScreenToWorldPoint( p); testGameObject.transform.position = pos; It works like a charm in Editor but in exe / apk, the GameObject dosn't follow the mouse: Example 1 Example 2 The GameObject that is supposed to follow the mouse is the "1" inside a circle

Get mouse position in world space

倖福魔咒の 提交于 2021-01-02 01:45:41
问题 I'm making a game using Unity and I have a little issue, I need to know the mouse position in world space, for that I try to set a GameObject at the mouse position using this code : Vector3 p = Input.mousePosition; Vector3 pos = Camera.main.ScreenToWorldPoint( p); testGameObject.transform.position = pos; It works like a charm in Editor but in exe / apk, the GameObject dosn't follow the mouse: Example 1 Example 2 The GameObject that is supposed to follow the mouse is the "1" inside a circle

URP/LWRP学习入门

☆樱花仙子☆ 提交于 2021-01-01 11:09:44
要了解什么是URP,首先得先了解什么是SRP.而要了解什么是SRP,又得先了解什么是RenderPipeline.我们先来看看RenderPipeline究竟是什么. RenderPipeline 在游戏场景中,有很多的模型效果需要绘制,如有不透明的(Opaque Object)、透明的(Transparencies)物体,有时候又需要使用屏幕深度贴图,后处理效果等.那么这些东西在什么时候来绘制,哪个阶段绘制什么东西,这就是由渲染管线来决定的. 默认渲染管线示意图 Unity默认的渲染管线如上图所示.我们来简单解释一下Forward Rendering的渲染管线. 在前向渲染中,相机开始绘制一帧图像时,如果你在代码中对一个摄像机设置了设置了 cam.depthTextureMode = DepthTextureMode.Depth; 那么该相机的渲染管线就会执行Depth Texture这一步操作.会把场景中所有RenderType=Opaque的Shader里面Tags{"LightMode" = "ShadowCaster"}的Pass全部执行一遍,把运行结果画到深度贴图中.所以如果相机开起了深度贴图,那么该相机的drawcall就会增加(所有Opaque的DrawCall翻了一倍).要是没有打开深度贴图,那么渲染管线就会略过这一步. 所以Shader 的Tags {

Attach text to a gameobject [closed]

北城以北 提交于 2021-01-01 07:39:27
问题 Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last month . Improve this question I know there are 2 ways to do it. But none of them works for me. The first way I tried is to create a gameObject and then put a cube(shape) and a canvas with Text in it. I set the position of shape, canvas(world space) and text to (0,0,0) so that they will stay

Visual Studio Code .NET framework not working when launched through unity

无人久伴 提交于 2020-12-31 14:54:27
问题 I am having trouble getting the .net framework to run inside vscode. I can get the .net framework running fine when I open vscode normally. However, when I open a .cs file in unity and use vscode as my default editor, I get error messages because the .net framework no longer works inside vscode. I need the framework for c# specific autocomplete and syntax errors. I have gotten comments on another post that has been closed saying I need to be more specific about this issue. This is not an

Visual Studio Code .NET framework not working when launched through unity

青春壹個敷衍的年華 提交于 2020-12-31 14:51:58
问题 I am having trouble getting the .net framework to run inside vscode. I can get the .net framework running fine when I open vscode normally. However, when I open a .cs file in unity and use vscode as my default editor, I get error messages because the .net framework no longer works inside vscode. I need the framework for c# specific autocomplete and syntax errors. I have gotten comments on another post that has been closed saying I need to be more specific about this issue. This is not an

Visual Studio Code .NET framework not working when launched through unity

时光怂恿深爱的人放手 提交于 2020-12-31 14:50:43
问题 I am having trouble getting the .net framework to run inside vscode. I can get the .net framework running fine when I open vscode normally. However, when I open a .cs file in unity and use vscode as my default editor, I get error messages because the .net framework no longer works inside vscode. I need the framework for c# specific autocomplete and syntax errors. I have gotten comments on another post that has been closed saying I need to be more specific about this issue. This is not an

How to set a Mixer's volume to a slider's volume in Unity?

蓝咒 提交于 2020-12-31 06:49:38
问题 I'm trying to make some audio settings. Here is my script: public AudioMixer masterMixer; public float masterLvl; public float musicLvl; public float sfxLvl; public void SetMasterVolume () { masterLvl = masterVolumeSlider.value; masterMixer.SetFloat("masterVol", masterLvl); } public void SetMusicVolume() { musicLvl = musicVolumeSlider.value; masterMixer.SetFloat("musicVol", musicLvl); } public void SetSfxVolume() { sfxLvl = sfxVolumeSlider.value; masterMixer.SetFloat("sfxVol", sfxLvl); } It

How to set a Mixer's volume to a slider's volume in Unity?

那年仲夏 提交于 2020-12-31 06:48:20
问题 I'm trying to make some audio settings. Here is my script: public AudioMixer masterMixer; public float masterLvl; public float musicLvl; public float sfxLvl; public void SetMasterVolume () { masterLvl = masterVolumeSlider.value; masterMixer.SetFloat("masterVol", masterLvl); } public void SetMusicVolume() { musicLvl = musicVolumeSlider.value; masterMixer.SetFloat("musicVol", musicLvl); } public void SetSfxVolume() { sfxLvl = sfxVolumeSlider.value; masterMixer.SetFloat("sfxVol", sfxLvl); } It