C
C
Chipu2018-09-13 14:30:43
C++ / C#
Chipu, 2018-09-13 14:30:43

Unity, blue screen after creating game, how to fix?

In Unity itself, everything works fine,
5b9a4a2b97e63008346113.png
but after building the application and running it inside, this is:
5b9a4a57c9a62391318279.png
Tell me how to fix this?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alex Maximovich, 2018-09-13
@Chipu

Wangyu that the scene is not included in the assembly. And if it is on, then it is in second place. The one that is created by default is loaded first. Check File->BuildSettings->ScenesInBuild.

G
GavriKos, 2018-09-13
@GavriKos

Build a developer build and look for errors in the console after running.
As one of the quick options - the necessary scenes were not added to the build / the wrong order of the scenes.

C
Chipu, 2018-09-13
@Chipu

The code:

using System.Collections;
using System.Collections.Generic;
using System.Text;
using UnityEngine;

public class Rules : MonoBehaviour
{


    DragAndDrop dad;

    public Rules()
    {
        dad = new DragAndDrop();
    }
  // Use this for initialization
  void Start ()
    {
    
  }
  
  // Update is called once per frame
  void Update ()
  {
      dad.Action();
  }
}

class DragAndDrop
{
    enum State
    {
        none,
        drag
    }

    private State state;
    private GameObject item;

    public DragAndDrop()
    {
        state = State.none;
        item = null;

    }

    public bool Action()
    {
        switch (state)
        {
            case State.none:
                if (IsMouseButtonPressed())
                    PickUp();
                break;

            case State.drag:
                if (IsMouseButtonPressed())
                    Drag();
                else {
                      Drop();
                      return true;
                }
                break;
        }

        return false;
    }

    bool IsMouseButtonPressed()
    {
        return Input.GetMouseButton(0);
    }

    void PickUp()
    {
        
        Vector2 clickPosition = GetClickPosition();
        Transform clickedItem = GetItemAt(clickPosition);
        if (clickedItem == null) return;
        item = clickedItem.gameObject;
        state = State.drag;
        Debug.Log("Picked up: "+item.name);

    }

    Vector2 GetClickPosition()
    {
        return Camera.main.ScreenToWorldPoint(Input.mousePosition);
    }

    Transform GetItemAt(Vector2 position)
    {
       RaycastHit2D[] figures = Physics2D.RaycastAll(position, position, 0.5f);
        if (figures.Length == 0)
            return null;
        return figures[0].transform;
    }

    void Drag()
    {
        item.transform.position = GetClickPosition();
    }

    void Drop()
    {
        state = State.none;
        item = null;
    }

}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question