unity3d

Unity3d dotween

无人久伴 提交于 2021-02-17 10:21:38
位置 1. 移动到指定位置 obj.transform.DOMove( new Vector3( 0 , 3 , 0 ), 2f); a. 单方向可以用DOMoveX、DOMoveY、DOMoveZ b. 本地坐标系版本:DOLocalMove (Scale、Rotate有类似方法) 2. 相对移动 // X轴方向向前移动100(如果.SetRelative(true)拿掉则表示移动到x坐标为100的位置) obj.transform.DOLocalMoveX( 100 , 1f).SetRelative( true ); obj.transform.DOLocalMove( new Vector3( 100 , 100 ), 2f).SetRelative( true ) //还可以使用方法 DOBlendableLocalMoveBy DOBlendableMoveBy (Scale、Rotate有类似方法) 透明度 obj.DOFade( 0 , 1f) // 注意不是transform 颜色 obj.DOColor(Color.gray, 1f) 缓动动画 // 缓动动画 效果demo: http://robertpenner.com/easing/easing_demo.html obj.transform.DOLocalMove( new Vector3( 100 ,

Getting error “no suitable method to override”

最后都变了- 提交于 2021-02-17 07:16:09
问题 I am trying some stuff with Unity and getting lot of this error where is always "no suitable method to override". For example: Assets/Standard Assets/Effects/ImageEffects/Scripts/Antialiasing.cs(86,30): error CS0115: `UnityStandardAssets.ImageEffects.Antialiasing.CheckResources()' is marked as an override but no suitable method found to override. Its look like that error is trivial, but I don't know C#, so don't know what with this. Can you show at this example, how fix this? Thanks! public

Unity - How to get GameObjects from a different scene?

血红的双手。 提交于 2021-02-17 06:32:47
问题 first of all, I'm a beginner so go easy on me. I'm trying to activate and deactivate GameObjects (players in the game) from another scene. Basically, I'm trying to change the player in the game scene by deactivate the current player model and activate the wanted player model in the game scene when the user press certain button in the shop scene, but i cant access the GameObjects (players in game scene) in the game scene from the shop scene. Does anyone know what can I do? 回答1: You will have

Unity - How to get GameObjects from a different scene?

生来就可爱ヽ(ⅴ<●) 提交于 2021-02-17 06:32:10
问题 first of all, I'm a beginner so go easy on me. I'm trying to activate and deactivate GameObjects (players in the game) from another scene. Basically, I'm trying to change the player in the game scene by deactivate the current player model and activate the wanted player model in the game scene when the user press certain button in the shop scene, but i cant access the GameObjects (players in game scene) in the game scene from the shop scene. Does anyone know what can I do? 回答1: You will have

Check if items are overlapping

女生的网名这么多〃 提交于 2021-02-17 05:52:21
问题 I have a few rooms which are placed randomly so I have to check if a room is overlapping. The rooms have a size of 10x10 and are for test reasons placed exactly side by side (they don't overlap in the scene). The Floor is a Transform which consists out of 1 or more Transforms (in this case out of one square but for other forms it it could be 2 or more). To check if they are overlapping I have this function which doesn't work. Debug log is always something between 3 and 61.. public bool

Shorten long switch case

纵饮孤独 提交于 2021-02-17 05:22:49
问题 So let me start by saying I am new to C#. I have a switch statement that currently has 10 different cases, however, I need to use it 3 different times (same 10 cases, different results per case), and each case there is only a slight change. I feel like I'm just repeating code, is there a way to shorten it? //Set the growth time of the crop based on what cropType. switch (cropType) { case 1: //Potatoes growth = 60; break; case 2: //Strawberries growth = 80; break; case 3: //Cabbages growth =

Instantiate a class that derives from MonoBehaviour [duplicate]

允我心安 提交于 2021-02-16 20:25:25
问题 This question already has answers here : Declaring a new instance of a class in C# (2 answers) Closed 9 days ago . Is there a way to instantiate a class that derives from MonoBehaviour such as the example bellow without getting the warning: "You are trying to create a MonoBehaviour using the 'new' keyword. This is not allowed. MonoBehaviours can only be added using AddComponent(). Alternatively, your script can inherit from ScriptableObject or no base class at all" Example: public class

Using yield WaitForSeconds

二次信任 提交于 2021-02-16 18:18:32
问题 I might be asking something that's extremely obvious and I have overlooked something, but I'm trying to create a pause before it does something. I have seen this being used in many places online - yield WaitForSeconds(2); However I get a syntax error of, "Error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) (CS1528) (Assembly-CSharp) Which confuses me as im not really sure what yield as a keyword really means or does, and im under the assumption that

Using yield WaitForSeconds

折月煮酒 提交于 2021-02-16 18:18:27
问题 I might be asking something that's extremely obvious and I have overlooked something, but I'm trying to create a pause before it does something. I have seen this being used in many places online - yield WaitForSeconds(2); However I get a syntax error of, "Error CS1528: Expected ; or = (cannot specify constructor arguments in declaration) (CS1528) (Assembly-CSharp) Which confuses me as im not really sure what yield as a keyword really means or does, and im under the assumption that

C# cant find a unity auto generated class

落花浮王杯 提交于 2021-02-16 15:08:11
问题 Okay so I'm learning to use the new InputActions and I've created a C# scripts using https://prnt.sc/oyaj5l And this is what I got: // GENERATED AUTOMATICALLY FROM 'Assets/PlayerControls.inputactions' using System.Collections; using System.Collections.Generic; using UnityEngine.InputSystem; using UnityEngine.InputSystem.Utilities; public class PlayerControls : IInputActionCollection { private InputActionAsset asset; public PlayerControls() { /// } } But when I try to create an PlayerControls