unity3d

Importing Google play services plugin: `Could not find a part of the path` exception

风格不统一 提交于 2021-01-28 08:10:06
问题 When I import the google play services plugin for unity it gives me an error: Could not find a part of the path "C:\ExternalWork\Island\Assets\GooglePlayGames\Plugins\Android\GooglePlayGamesManifest.plugin\AndroidManifest.xml". This is the complete stack trace: System.IO.DirectoryNotFoundException: Could not find a part of the path "C:\ExternalWork\Island\Assets\GooglePlayGames\Plugins\Android\GooglePlayGamesManifest.plugin\AndroidManifest.xml". at System.IO.FileStream..ctor (System.String

Slant Physics Raycast Implementation

人走茶凉 提交于 2021-01-28 07:10:56
问题 For my 3d car game, I was doing Physics raycast to detect obstacles and based on detect take turn left or right side. Currently, I was doing straight raycast and I can't able to detect left and right side existed obstacles. So I decided to do little bit slant raycast to detect something from the left and right side. The following image explains a better way my question: This code is running at present: Ray rayRight = new Ray(thisTransform.position + Vector3.up * 0.2f + thisTransform.right *

Confused on Clipper in C#

末鹿安然 提交于 2021-01-28 07:09:58
问题 I'm creating a 2D game in Unity which has procedurally placed tiles. I want to simplify the collision geometry using Angus Johnson's Clipper library (specifically the union function), but I'm running into an issue with the library returning empty solutions and I'm not sure why. For reference, here are the Polygon Colliders I've been using to test. And here is a simplified version of the function I'm using to combine the geometry: List<List<Vector2>> unitedPolygons = new List<List<Vector2>>();

How can i stop a character from double jumping?

ε祈祈猫儿з 提交于 2021-01-28 06:01:09
问题 I'm trying to make the character stop jumping when in the air, but the problem is that it can jump when colliding with walls. So i tried to make a certain amount of time pass by before the character could jump again in the script below, but for some reason it doesn't work. If anyone has any more efficient ways of doing this i would definitely appreciate it. using System.Collections; using System.Collections.Generic; using UnityEngine; public class PlayerMovement : MonoBehaviour { public float

Sort GameObjects from an array to a reference point in space

夙愿已清 提交于 2021-01-28 05:35:12
问题 I have some GameObject in an array and I'd like to sort them by distance based on a point in space. So basically I'm searching for an point sorting by distance algorithm. I'm sure this is basic sorting algorithm stuff but I couldn't find a valid answer on Google so far. Thanks for the help ! 回答1: This should get you started: System.Array.Sort<GameObject>(arrayOfGameObjects, (g1, g2) => (Vector3.Distance(target,g1.transform.position) < Vector3.Distance(target,g2.transform.position))?-1:1); 回答2

How to solve “Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types” Android error?

[亡魂溺海] 提交于 2021-01-28 05:15:00
问题 I'm working in an App with Unity3D. Im using my own utilities DLL with some classes. I've been working for months now, and made lots of builds/compilations with no problem. Last week added a new class to the DLL, it worked well in my PC but when I builded the project and used it in my Android device it stopped working. The Android Monitor program shows me that error: "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" The types that Newtonsoft can find

How do I make a generic delegate using a type in C#?

江枫思渺然 提交于 2021-01-28 05:11:12
问题 If I have a type, like: Type type = myObject.GetType (); How do I make a generic delegate that uses objects of that that type as a parameter? I would expect code something like: myDelegate = Action<type> (type parameter); The above code obviously won't and doesn't work as is, but how can I make it work? Can I even make it work? Ultimately, I have a dictionary of Dictionary < Type, List < Action < > >, which holds a type and a list of delegates that should take an object of that type as

Dynamically change property of Shader

戏子无情 提交于 2021-01-28 02:50:34
问题 I have a shader on a gameObject in Unity, Lets call it FooShader. In FooShader there is a public property called _fooVal I want to update in real time. I've created a blank C# script on the same gameObject. My first problem is how do I reference this FooShader shader? And then once I have a correct reference change its _fooVal property? I've tried using the following to get a reference to the Shader but it doesn't work. gameObject.material._fooVal 回答1: If I'm understanding your question

Debug of z-axis-rotation is not 0, while in inspector it is 0

此生再无相见时 提交于 2021-01-28 01:54:25
问题 In the inspector the z-axis rotation of my transform is 0. But when i debug this using these lines of code: Debug.Log("local-Euler-z: " + transform.localEulerAngles.z); Debug.Log("global-Euler-z: " + transform.eulerAngles.z); Debug.Log("local-rot-z: " + transform.localRotation.z); Debug.Log("global-rot-z: " + transform.rotation.z); you can see in my screenshot that i don't get 0 as value. 回答1: First of all, values you're getting are really small. xE+/-y is an exponential floating point number

WaitForSeconds on C#

孤街醉人 提交于 2021-01-28 01:43:31
问题 Look at this simple code: function Start() { yield WaitForSeconds (4); Application.LoadLevel(1); } It works! I'm trying to make something similiar using C#, but the processor just ignore the WaitForSeconds. This is my code in C#: using UnityEngine; using System.Collections; public class openingC : MonoBehaviour { void Start() { executeWait(5); Application.LoadLevel(1); } void executeWait(float aux) { StartCoroutine(Wait(aux)); } IEnumerator Wait(float seconds) { yield return new