unity5

Detect when VideoPlayer has finished playing

北慕城南 提交于 2020-01-11 09:44:19
问题 I have a MovieController class that manages videos in my project. I'm using the new video player component introduced in Unity 5.6. I would like to call a method when a movie has finished playing. So far, this method is only a Debug.Log , as you can see: using UnityEngine; using UnityEngine.Video; public class MovieController : MonoBehaviour { private VideoPlayer m_VideoPlayer; void Awake () { m_VideoPlayer = GetComponent<VideoPlayer>(); m_VideoPlayer.loopPointReached += OnMovieFinished; //

How to apply jump both to controller and player for an endless runner 3D in unity

一个人想着一个人 提交于 2020-01-07 06:34:17
问题 I'm trying to develop a 3D endless runner game in unity 5. The problem I'm facing is jump. How can I apply a jump to an endless runner? I've been searching and surfing through the internet with no luck. I did find some codes but when I try to apply them, they didn't work. Also How do I adjust the character controller to go up with the animation? A help would be really appreciated. This is the playerMotor.cs code. private Vector3 moveVector; private float verticalVelocity = 0.0f; private float

Unable to use a native android plugin for Unity

♀尐吖头ヾ 提交于 2020-01-07 05:22:32
问题 I wish to use this native plugin for Android devices via Unity. For some reason the plugin is just now working. When I run it on a real device the game crashes. I am using Unity 5.5.2f1 personal, my phone is Samsung Edge 6 with Marshmallow api. I have placed the jar file inside Assest/Plugins/Android. I can't figure out what is the cause for this error. Do you know what is wrong here? This is part of my code: private AndroidJavaObject plugin; void Start () { plugin = new AndroidJavaClass("jp

I'm getting warning on LineRenderer SetWidth that it's obsolete how should i fix it?

ぃ、小莉子 提交于 2020-01-07 03:50:20
问题 lineRenderer.SetWidth(startWidth, endWidth); lineRenderer.SetVertexCount(linePoints.Count); On both lines same warning: 'LineRenderer.SetVertexCount(int)' is obsolete: 'SetVertexCount has been deprecated. Please use the numPositions property instead.' And 'LineRenderer.SetWidth(float, float)' is obsolete: 'SetWidth has been deprecated. Please use the startWidth, endWidth, or widthCurve properties instead.' I tried this then: lineRenderer.startWidth(startWidth, endWidth); But then getting

I'm getting warning on LineRenderer SetWidth that it's obsolete how should i fix it?

家住魔仙堡 提交于 2020-01-07 03:50:11
问题 lineRenderer.SetWidth(startWidth, endWidth); lineRenderer.SetVertexCount(linePoints.Count); On both lines same warning: 'LineRenderer.SetVertexCount(int)' is obsolete: 'SetVertexCount has been deprecated. Please use the numPositions property instead.' And 'LineRenderer.SetWidth(float, float)' is obsolete: 'SetWidth has been deprecated. Please use the startWidth, endWidth, or widthCurve properties instead.' I tried this then: lineRenderer.startWidth(startWidth, endWidth); But then getting

how to create an enum for a prefab to be instantiated with an image for sprite

会有一股神秘感。 提交于 2020-01-07 03:49:35
问题 Basically I’ve created a prefab, “badGuy” of which there are three types. Each has it’s their own sprite images. So I created the following enum in a script attached to my badGuy prefab: public enum BadGuyType { green, blue, red } All along I have been using one image for my prefab since I didn’t have a enum. The badGuy game object had a public property for me to add it through the inspector and instantiate it a number of times as below: public GameObject badGuy; //I set this in the inspector

Ignore other layers collider in raycast [duplicate]

☆樱花仙子☆ 提交于 2020-01-06 21:41:10
问题 This question already has answers here : Raycasting only to a particular object (2 answers) Using Layers and Bitmask with Raycast in Unity (2 answers) Closed 2 years ago . I am willing to raycast specific layer and ignore other layers no matters its colider is above to my navPoint layer object? int specificLayerMask = LayerMask.GetMask("NavPoint");//raycast only this layer ignore others if (Physics.Raycast(raycastObject.transform.position, fwd, out objectHit, specificLayerMask))//50 {} the

Unity finding child's transform component vs traversing parent's transform

半腔热情 提交于 2020-01-06 19:38:33
问题 so the idea is that I want to get a GameObject with a specific tag, which is a child of a GameObject , using my own method called FindChildWithTag() . Below there are 2 different methods, which I believe, got a similar purpose. FIRST void GameObject FindChildWithTag(string tag) { GameObject temp = GetComponentsInChildren<Transform>(). Select(x => x.gameObject). FirstOrDefault(x => x.tag == tag && x != transform); return temp; } SECOND void GameObject FindChildWithTag(string tag) { foreach

Having Trouble With Post Processing Effects

[亡魂溺海] 提交于 2020-01-06 18:11:45
问题 I'm trying to write a post processing effect that alters what is eventually drawn to the screen. However, that requires getting what's currently being drawn, modifying it, and then drawing it back. The first two steps seem to work just fine. The third step....renders all gray. public class PostProcess : MonoBehaviour { void OnRenderImage(RenderTexture src, RenderTexture dest) { Texture2D proc = new Texture2D(src.width, src.height); proc.ReadPixels(new Rect(0, 0, src.width, src.height), 0, 0);

Unity: Weird scene transition bug after adding a “Persistent-Scene” with a GameManager

只谈情不闲聊 提交于 2020-01-06 18:11:27
问题 I made a pretty basic 2D game to learn. I have 2 Scenes , and switching between them worked great. I used empty gameObjects as Start/Exit point of the Scene , so that the game would know to put player on point X after exiting through point X (for example exit outside house if I walk out the door). Then I added a " Scene0 ", to use for persistent general scripts like GameManager, Sounds, Music, etc. With just one object called "Controller" that I DontDestroyOnLoad(). After adding this Scene