unity3d

invoke() Function in unity [duplicate]

我怕爱的太早我们不能终老 提交于 2021-02-05 12:19:42
问题 This question already has an answer here : When i use Invoke to a method i want to use i can't call it anymore? (1 answer) Closed last month . Its almost my first time using C sharp and unity. I am trying to use invoke() function in unity but its giving the error "Trying to Invoke method: EndGame.Restart1 couldn't be called." public class EndGame : MonoBehaviour { bool GameHasEnded = false; public float Timer = 1f; public void endgame() { if (!GameHasEnded) { GameHasEnded = true; Debug.Log(

Not able to get TextMeshPro text to variable slot in Unity

本小妞迷上赌 提交于 2021-02-05 12:19:14
问题 using TMPro; public TextMeshPro _livesText; public TextMeshPro _scoreText; I am unable to drag the text from the Hierarchy to the variable slot in Inspector. Why is it happening. Please help. 回答1: You seem to speak about a TextMeshProUGUI which in the Inspector is called TextMeshPro - Text(UI) . Note that TextMeshPro != TextMeshProUGUI! There is no inheritance between those two. (Similar to Unity build in TextMesh and UI.Text ) If you want one general field for both types then you need to use

How to get the JSON content of a HTTP Post request?

ぐ巨炮叔叔 提交于 2021-02-05 12:16:12
问题 I want to send a JSON file from my Unity application to my Laravel backend. It seems there is something wrong with my post request but I can't figure out what it is. Sending the request using Unity public void SendRequest() { // serializable struct OfferData data = new OfferData(OfferSize.JUMBO, OfferType.AD, 50, 10); StartCoroutine(RequestHandler.Post(API_URL + "shop/store", JsonUtility.ToJson(data), (response) => { if (response == null) { return; } // success Debug.Log(response); })); } The

Check whether an array in the inspector is empty

心已入冬 提交于 2021-02-05 11:36:24
问题 I have a public array that should be filled in the inspector, and I want to do something if that array is empty. That array is empty in the inspector "size = 0" public GameObject[] objects; void CheckArray () { if (objects.Length < 0 ) // this doesn't work { Debug.Log("Empty!"); } else { Debug.Log("Not Empty"); // this gets logged out } } The above doesn't work, I tried something else but also doesn't work: void CheckArray () { if (objects == null ) // this doesn't work { Debug.Log("Empty!");

Failed to update Android SDK Package List - Unity 2019.2.10f1

不羁岁月 提交于 2021-02-05 11:31:08
问题 When I try to export the game build for the Android platform, I started getting this error: Within the Project Settings - Minimum API Level and Target API Level not get loaded anyhow! While I have used all default Unity provided settings to export Android build. Here is the image to illustrate this: Now what to do to solve this error? I have already read all the threads related to same problem but overall I can't able to find the solution that actually worked for me. 回答1: I just got the same

unity run a function as long a button is pressed in the inspector

廉价感情. 提交于 2021-02-05 10:54:05
问题 I'm a newbie in Unity Using Unity Inspector i have setup a button that makes a callback to a function (OnClick), it works fine but only once, to fire the action again i need to release and click the button again How can i make that the function keeps running over and over as long as the button is pressed? (like a machine gun) public void MoveLeft ( ) { transform.RotateAround(Camera.main.transform.position, Vector3.up, -rotation / 4 * Time.deltaTime); infopanel.RotateAround(Camera.main

Custom made a* Path finding isn't working very well

我们两清 提交于 2021-02-05 09:46:53
问题 I am making a pathfinding algorithm on a map with coordinates, for a project with rivers. I looked at how a* worked, and I started to understand it, so I made it in my own code. The issue is that is doesn't work at all. The pathfinder is only making the first two squares of the river, and then just giving up. I do not know the issue. Here is my code: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; public class APath { public bool

Custom made a* Path finding isn't working very well

╄→гoц情女王★ 提交于 2021-02-05 09:46:34
问题 I am making a pathfinding algorithm on a map with coordinates, for a project with rivers. I looked at how a* worked, and I started to understand it, so I made it in my own code. The issue is that is doesn't work at all. The pathfinder is only making the first two squares of the river, and then just giving up. I do not know the issue. Here is my code: using System; using System.Collections; using System.Collections.Generic; using UnityEngine; using System.Linq; public class APath { public bool

C# Unity the namespace '<global namespace>' already contains a definition for

别说谁变了你拦得住时间么 提交于 2021-02-05 09:44:38
问题 I am studying access modifiers and I came across the following error in my code. Can someone explain to me and help me solve it? Assets\Testes\Scripts\modificadoracesso.cs(40,7): error CS0101: The namespace '< global namespace >' already contains a definition for 'Felino' using System; using System.Collections; using System.Collections.Generic; using UnityEngine; public class modificadoracesso : MonoBehaviour { Felino gatoFase1; // criar objeto Felino gatoFase2; Filha fi; // Start is called

Unity c#: making an array of class type equal to FindObjectOfType [closed]

天涯浪子 提交于 2021-02-05 09:41:38
问题 Closed. This question is not reproducible or was caused by typos. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 1 year ago . Improve this question In my c# script I am working on, I have this code public class Attractor : MonoBehaviour { public Rigidbody rb; private void FixedUpdate() { //physics code Attractor[] attractors = FindObjectOfType<Attractor>(); } I am currently getting an error saying Error