mesh – The unit inflates the number of vertebrae / vertexes but I do not have any light?

Ok, I have a problem with several meshes that have a lower poly number in the mixer, then when I export as fbx and I put in the unit, the number of poly / vertex goes up. I read here

https://forum.unity.com/threads/why-does-light-add-verts-and-tris.291872/

that Unity recalculates well others for real time lights, but I have no light in my scene and the lighting is on:

enter the description of the image here

Here are the mesh import settings:

enter the description of the image here

The number of polyphonies slips significantly down (by 10) and I have to remedy that. The mesh has not yet applied materials. What can I do?

c # – Should my classes have separate constructors only for unit tests?

Never create separate code paths for unit tests. This would defeat the purpose of unit testing because you are testing one code path in your unit tests and running another one in production.

For some reason, that seems to be insufficient because I'm just repeating part of your question. You already know that you are running a different code in your unit tests. The comment you put in your builder says so. It 's like asking if it' s appropriate to take someone 's cell phone because it belongs to him and not to you and you want to have it. to have.

Would an argument from a consensus help? Do not do this because no one does it. Someone who knows better will be shocked. Even worse, someone who knows better could learn from it, which would be bad, because … I feel like I'm still going around in circles. But luckily, that has weight, what others say you should not do that.

I could perhaps show you that there is a better way: addiction reversal and dependency injection. The dependency inversion means that you depend on abstractions (like interfaces) instead of concrete implementations. This is not possible if your class creates its own dependencies, that is, where dependency injection comes in.

Instead of creating instances of dependencies, you define abstractions describing how your class should use them. For example, if ExternalResource If you download files, you can create an interface like this:

IFileStorage public interface
{
byte[] GetFile (string filePath);
}

Then you create your class like this:

Public class DoesSomething: BaseClass
{
private read-only IFileStorage _fileStorage;

public DoesSomething (IFileStorage fileStorage)
{
_fileStorage = fileStorage;
}
}

Now you do not need a separate builder. Your unit tests can call the real constructor and move into a mockup or a double test, which means an implementation of IFileStorage it returns exactly what you want. In this way, you can write tests on the behavior of your class if the file contains this or that or nothing at all, without using a concrete implementation of IFileStorage.

For example, if you want to see how your class behaves if IFileStorage return an empty array of bytes? You can use a frame such as Moq or just do this:

Public class FileStorageThatReturnsEmptyArray: IFileStorage
{
public byte[] GetFile (string filePath)
{
return a new byte[] {};
}
}

Then your test subject looks like this:

var subject = new DoesSomething (new FileStorageThatReturnsEmptyArray ());

Is not it better? Your unit tests are worth something because they test your class from end to end, allowing it to behave exactly as it does in production.

Certainly, in production, you will have a concrete implementation of IFileStorage instead of a double test. But the fact is that Something it's all the same. A IFileStorage is the same as another.

I hope that showing how other developers have solved this problem helps.

But the direct answer to your question is no, you should never create separate code paths (including constructors) for unit tests only. Always test the code that you will execute to do it.

Some sources have also suggested that writing new code by copying / pasting an old code is also undesirable. If they see that something is wrong with the code, they can not fix it, and they have to copy and paste, they feel sad.

laravel 5.7 – Authenticate the user with the unit test

I had time, no questions asked, but I needed something on the web (I may be doing bad research).

Well, I'll tell you once, I do unit tests in Laravel 5.7 and more specifically when I do the test to authenticate a user, the test never happens, here is my code:

/ ** @test * /
public service authentatingUnUser ()
{

$ user = User :: where (& # 39; email; test@test.com') -> first ();
$ this-> get (& login) -> assertSee (& # 39; Connection & # 39;);
$ credentials = [
        "email" => $user->email,
        "password" => $user->password
    ];

$ response = $ this-> post (& # 39; / login & # 39 ;, $ identifiers);
$ response-> assertRedirect (& # 39; / welcome & # 39;);
$ this-> assertCredentials ($ credentials);
}

The error that PHPUnit gives me is the following:

F 1
/ 1 (100%)

Time: 1.47 seconds, memory: 16.00 MB

There was a failure:

1) Tests Unit LoginTest :: authenticationatingUnUser Code response
[419] is not a redirect status code. Failed to assert that false is
true

/ home / vagrant / Projects / my new project / vendor / laravel / framework / src / Illuminate / Foundation / T
/home/vagrant/Projects/mynewproject/tests/Unit/LoginTest.php:40

CHESS! Tests: 1, Assertions: 2, Chess: 1.

The identification information is correct, you must pass the test. When I comment on line 45, what would it be:

$ response-> assertRedirect (& # 39; / welcome & # 39;);

The error that PHPUnit displays is another:

F 1
/ 1 (100%)

Time: 2.16 seconds, memory: 16.00 MB

There was a failure:

1) Tests Unit LoginTest :: authenticationatingUnUser The identification information provided
are invalid Failed assertion that false is true.

/home/vagrant/Projects/mynewproject/vendor/laravel/framework/src/Illuminate/Foundation/Testing/Concerns/InteractsWithAuthentication.php:114
/home/vagrant/Projects/mynewproject/tests/Unit/LoginTest.php:41

CHESS! Tests: 1, Assertions: 2, Chess: 1.

Try to validate but say that the credentials are not valid, while they are, start the session and everything will be fine.

I hope you can enlighten me a bit because I really do not know why it does not work.

Greetings

P.D .: Laravel 5.7 has 2 folders in / tests which are / Feature and / Unit my tests are saved in Unit

unit – The hard-coded triangle in the HLSL geometry shader does not display on the screen

In Unity, I plan to use a geometry shader to process points in quads and I do not quite understand why I'm not getting output from my geometry shader. I have edited it to a minimum working example, as seen here:

Shader "foo / bar"
{
SubShader {
Cull Off
Lighting off
Zécrivez

Pass{
CGPROGRAMME
#pragma vertex green
#pragma fragment frag
#pragma geometry geom

struct appdata {
top float4: POSITION;
};
struct v2g {
top float4: POSITION;
};
struct g2f {
top float4: POSITION;
};

v2g green (appdata v) {
v2g o = (v2g) 0;
o.vertex = v.vertex;
return o;
}

                [maxvertexcount(4)]
                void geom (point v2g p[1], inout TriangleStream tristream)
{
g2f o = (g2f) 0;
o.vertex = float4 (0.1, 0.1, 0, 0);
tristream.Append (o);
o.vertex = float4 (0,1, 0,9, 0, 0);
tristream.Append (o);
o.vertex = float4 (0.9, 0.9, 0, 0);
tristream.Append (o);
}


fixed4 frag (g2f i): COLOR
{
fixed return4 (1,1,1,1);
}
ENDCG
}
}
}

I would expect to draw a white triangle covering just under half of the texture I render. Instead, it displays all the black, as before the shader.

Until here I have:

  • Removing all possible sources of slaughter that I can think of
  • Make sure my configuration works similarly when rendering a mesh
  • Checked that I get entry and being run
  • and scoured the very limited amount of documentation available

I am all outgoing ideas. If someone has even a minor clue about what I am doing wrong, please let me know. Thank you.

-Fraser

unit – Bad movement with inverse kinematics?

I write the IK character to look at the object "enemy" direction. If the enemy is above him, he looks at the enemy. The problem here is when the enemy comes out of the reach of the characters. The character should look forward and he does it. But for a second, you can see some sort of glitch movement. Here is my script

using System.Collections;
using System.Collections.Generic;
use UnityEngine;

Public class LookingScript: MonoBehaviour
{

private animator;
PlayerMovement private _active; // check if the enemy is inside the character or not
public bool ikActive = false;
public GameObject rightHandObj;
public GameObject leftHandObj;
Public transformation lookObj = null;
public floating announcement, nd;

empty Start ()
{

_active = GetComponent();
animator = GetComponent();

}

void Update ()
{

lookObj = _active.enemy; // enemy object to watch.

if (_active.actives == false && lookObj) // This allows smooth motion for IK.
{
ikActive = true;
ad = ad + Time.deltaTime;
sd = sd + Time.deltaTime;
if (ad> = 1)
{
ad = 1;
}
if (sd> = 0.15f)
{
sd = 0.15f;
}

}
other
{
sd = sd - Time.deltaTime;
ad = ad - Time.deltaTime;
ikActive = false;
if (ad <= 0)
{
ad = 0.0f;
}
if (sd <= 0)
{

sd = 0.0f;
}
}

} // end Uploade

void OnAnimatorIK ()
{
if (moderator)
{

if (ikActive == true)
{

if (lookObj! = null)
{
animator.SetLookAtWeight (ad, sd, 0, 0, 0);
animator.SetLookAtPosition (lookObj.position);

}

if (rightHandObj! = null)
{
animator.SetIKPositionWeight (AvatarIKGoal.RightHand, 1);
animator.SetIKRotationWeight (AvatarIKGoal.RightHand, 1);
animator.SetIKPosition (AvatarIKGoal.RightHand, rightHandObj.transform.position);
animator.SetIKRotation (AvatarIKGoal.RightHand, rightHandObj.transform.rotation);
}

if (leftHandObj! = null)
{
animator.SetIKPositionWeight (AvatarIKGoal.LeftHand, 1);
animator.SetIKRotationWeight (AvatarIKGoal.LeftHand, 1);
animator.SetIKPosition (AvatarIKGoal.LeftHand, leftHandObj.transform.position);
animator.SetIKRotation (AvatarIKGoal.LeftHand, leftHandObj.transform.rotation);
}

}

other
{

animator.SetLookAtWeight (ad, sd, 0, 0, 0);

if (rightHandObj! = null)
{
animator.SetIKPositionWeight (AvatarIKGoal.RightHand, 1);
animator.SetIKRotationWeight (AvatarIKGoal.RightHand, 1);
animator.SetIKPosition (AvatarIKGoal.RightHand, rightHandObj.transform.position);
animator.SetIKRotation (AvatarIKGoal.RightHand, rightHandObj.transform.rotation);
}

if (leftHandObj! = null)
{
animator.SetIKPositionWeight (AvatarIKGoal.LeftHand, 1);
animator.SetIKRotationWeight (AvatarIKGoal.LeftHand, 1);
animator.SetIKPosition (AvatarIKGoal.LeftHand, leftHandObj.transform.position);
animator.SetIKRotation (AvatarIKGoal.LeftHand, leftHandObj.transform.rotation);
}

} // end else

}
} // end IK

}

Can anyone understand the mistake I've made here?

dependency injection – Unit test for a method of a class using the constructor DI (prism)

The problem is that IEventAggregator is part of the prism. All objects that use it therefore depend on this library.

In the case of your unit tests, this is not really a problem. It does not matter if they refer to some additional libraries.

However, if you want to use your same objects in a web version of your application, for example. Then the prism library would be clumsy and useless.

Try to keep your business objects out of the way of implementing a logic requiring specific libraries.

So, in this case, for example, if you use prizm in your view templates, they are linked to your WPF application, which uses prism in turn. But you would like your models and interfaces to be free of prism references.

PS. Obviously, as for any "best practice", you are free to take shortcuts where

unit – Adding text to gameobject

I'm trying to create a word game that falls as z-type (code here). I created 3 game objects and I want the words to be added as text to these game objects, as if a health bar was added to the enemies, etc. This is the spawning script that breeds the word on the screen.

public GameObject wordPrefab;
public Transformer wordCanvas;

WordDisplay public SpawnWord ()
{
Vector3 randomPosition = new Vector3 (Random.Range (-2.0f, 2.0f), 7.0f, 0);
GameObject wordObj = Instantiate (wordPrefab, randomPosition, Quaternion.identity, wordCanvas);
WordDisplay wordDisplay = wordObj.GetComponent();
returns wordDisplay;
}

At the present time, words are generated at a random x position and a y position of 7.0. Instead, how can I assign words to the game objects I've created?

edit

I've created a spawner that breeds 3 enemies at the top of the screen and they start falling down. Here is the script attached to the enemy game objects:

public float fallSpeed ​​= 1.0f;
public GameObject wordPrefab;
Transform private parent;

WordDisplay public SpawnWord ()
{
Vector3 randomPosition = new Vector3 (Random.Range (-2.0f, 2.0f), 7.0f, 0);
GameObject wordObj = Instantiate (wordPrefab, randomPosition, Quaternion.identity, parent);
WordDisplay wordDisplay = wordObj.GetComponent();
returns wordDisplay;
}

// The update is called once per image
void Update () {
transform.Translate (0, -fallSpeed ​​* Time.deltaTime, 0);
}

I've also removed the SpawnWord () method from the wordspawner script. However, words do not appear with enemy game goals. There is another script called WordTimer. You do not know where to add this code. This is original code that is on github.

public WordManager wordManager;
public float time = 1.5f;
private float nextWord = 0f;

void Update ()
{
if (Time.time> = nextWord)
{
wordManager.AddWord ();
nextWord = time.time + delay;
delay * = 0.95f;
}
}

unit – Prefabricated imported from a group of assets do not light properly

This only happens in my main game project. I have tested it in 2 other empty projects, both in multiple versions of unit (2018.3.0f2 and 2018.3.2f1).

The strange thing is that if I look at the material, it contains the correct material (identical to what I assigned before building the assetbundle), but if I go manually in the shader menu and click again on the even shader, the lighting is fixed.

Here are the settings I used in the screen capture below:

  • Default Skybox
  • Sun shot straight down and 0 intensity
  • Ambient mode set to color
  • Ambient color # 111
  • No post-treatment
  • The template was imported from a group of assets and generated at runtime
  • All lighting is dynamic

Here are some screenshots: https://imgur.com/a/yV0wE0d

I just want to emphasize the fact that the only difference between the two images is that I've reassigned the same shader to the material.

Ideas?

(A workaround has been suggested here but the underlying problem still persists: https://www.reddit.com/r/Unity3D/comments/ah39jm/prefabs_imported_from_asset_bundle_are_not/)

unit – Loading a list of items from JSON, all entries after the first are null

(I've recently posted a very similar question here and the answer I received was helpful, but I was advised to ask a new question, and here it is.)

I'm developing a Unity game that includes a multiple choice quiz. I've set what I consider to be a properly formatted .json file (the quiz question, four answer choices, the correct answer and an explanation of the answer) (which I've checked with a .json formatter) in the StreamingAssets folder of the Unity project. I have created a custom class for the question, the four answer choices, the correct answer, and the explanation of the answer. I'm trying to load all the contents of the .json file into a table, "questions," and then copy that table to another table, "questionsCopy." To avoid repeating questions, when a question is used during the game, I will delete it (and the corresponding answer choices, correct answer and explanation) from the questionsCopy table. (I have not yet developed the graphical interface to display the question, the answer choices and possibly the correct answer and explanation.)

Here are the relevant sections updated from what I've coded so far:

1) The REVISED custom class:

using System.Collections;
using System.Collections.Generic;
use UnityEngine;

// ************************************************ *******************
// see: https://gamedev.stackexchange.com/questions/166759/trying-to-load-json-questions-and-answers-int-a-multiple-choice-quiz-game-in-u
[System.Serializable]
Public class QuestionCollection
{
public QuestionChoicesAnswerHintExplanation[] questions;
}
// ************************************************ *******************


[System.Serializable]
Public class QuestionChoicesAnswerHintExplanation: MonoBehaviour {

public channel[] question; // An array of strings (rather than just a string) to preserve the spacing of lines, which does not work well with .json
public channel[] answerChoices;
public int correctAnswerIndex;
public channel index;
public channel explanation;

}

2) From the REVISED GameController:

                public QuestionCollection questionCollection; // see: https://gamedev.stackexchange.com/questions/166759/trying-to-load-json-questions-and-answers-int-a-multiple-choice-quiz-game-in-u

public QuestionChoicesAnswerHintExplanation[] questions; // This is the fixed size chart of questions, choice of answers, answers, tips and explanations.
Private static list questionsCopie; // This is the resizable list (originally a copy of the table). The size of this list will decrease as we remove items after presenting each question.
private QuestionChoicesAnswerHintExplanation currentQuestion; // The current question drawn at random.
private int randomIndex; // the index used to choose the random question.

chain path; // The path of the .json file containing the questions, the answer choices, the correct answer index, the tips, the explanations.
string jsonString; // The contents of the .json file.

In the REVISED start () in the GameController:

                path = Application.streamingAssetsPath + "/questionsAndAnswers.json";
jsonString = File.ReadAllText (path);

questionCollection = JsonUtility.FromJson(JsonString); // questionCollection contains an array of question-answer answer-answer-index-explanation objects
questions = questionCollection.questions;


// questions = JsonUtility.FromJson(JsonString);

Debug.LogWarning ("questionCollection:");
Debug.LogWarning (questionCollection);

Debug.LogWarning ("Questions:");
Debug.LogWarning (questions);

if (questionsCopy == null || questionsCopy.Count == 0) // A list with zero items is not always null.
{
// questionsCopy = questions.ToList(); // <---- It was incorrect.
questionsCopy = questions.ToList();

Debug.LogWarning ("questionsCopy:");
Debug.LogWarning (questionsCopy);
Debug.LogWarning ("questionsCopy.Count:");
Debug.LogWarning (questionsCopy.Count);
Debug.LogWarning ("questionsCopy[0]: ");
Debug.LogWarning (questionsCopy[0])
Debug.LogWarning ("questionsCopy[1]: ");
Debug.LogWarning (questionsCopy[1])
Debug.LogWarning ("questionsCopy[2]: ");
Debug.LogWarning (questionsCopy[2])

}

PickRandomQuestion ();

Further down in the GameController, here is the REVISED PickRandomQuestion ():

                public void PickRandomQuestion ()
{
randomIndex = Random.Range (0, questionsCopy.Count);
currentQuestion = questionsCopy[randomIndex];
questionsCopy.RemoveAt (randomIndex);
}

3) Here is the contents of the .json file in the StreamingAssets folder:

                {
"questions":

    [

{
     "question": ["Trinculo admits 'I have been in such a pickle...' in this comedy:"],
"AnswerChoices": ["'The Tempest'", "'Henry 4, Part 1'", "'Henry 5'", "'The Merry Wives of Windsor'"],
"correctAnswerIndex": 0,
"index": "Index: Trinculo is beached on an island.",
"Explanation": "" Henry 4, Part 1 "and" Henry 5 "are both stories - being in a" pickle "usually means being in a dilemma.A wider view of this passage reveals that Trinculo is drunk:  n  nAlonso: And Trinculo is ripe: where should they find this great liquor that has gilded them? How can you be in this pickle? Finally, you fear that I never fear falling into bones: I will not be afraid the flies.  n  n "The Tempest" 5.1. "
}
{
"question": ["In 'Hamlet,' this character remarks: 'Neither a borrower nor a lender be; nFor loan oft loses both itself and friend, nAnd borrowing dulls the edge of husbandry. nThis above all: to thine own self be true,nAnd it must follow, as the night the day,nThou canst not then be false to any man:'"],
"AnswerChoices": ["Fortinbras", "Gertrude", "Polonius", "The Ghost of Hamlet's Father"],
"correctAnswerIndex": 2,
"hint": "Hint: This character is very talkative.",
"Explanation": "The wordy Polonius speaks to his son Laertes." Hamlet "1.3."
}
{
"question": ["Roger Daltrey, well into his career with The Who, played the roles for both Dromios, the twin servants, in a 1983 BBC production of:"],
"AnswerChoices": ["'King John'", "'King Lear'", "'Coriolanus'", "'The Comedy of Errors'"],
"correctAnswerIndex": 3,
"hint": "Hint: This piece is a comedy.",
"explanation": "The comedy of errors."
}

]}

It does not work, though. In the console, I receive correct values for questionsCopy.Count and for randomIndex. But I get null values for questionsCopy[0], questionsCopie1 and questionsCopie[2]. I would appreciate any helpful advice. Thank you.

unit – Camera to the right of the character

I'm trying to create a camera like in Fortnite or Armament of war. His focus must be to the right of the character:enter the description of the image here

But when I rotate the camera, the character shivers slightly. Lerping and multiplying by Time.deltatTime do not help.

This is my code:

                use UnityEngine;

    [RequireComponent(typeof(Camera))]

    Public class ThirdPersonCamera: MonoBehaviour
{
        [Header("Sensitivity")]
        [SerializeField]    private float xSensitivity;
        [SerializeField] private float y Sensitivity;

    [Header("Limit angles")]
    [SerializeField]    private float upLimit;
    [SerializeField] private float downLimit;

    [Header("Positioning")]
    [SerializeField]    Vector3 offset;
    [SerializeField] private float maxDistanceFromPlayer;
    [SerializeField] private transformation player;

private rotation floatAboutX;
rotation of private floatsAboutY;

// Start is called before the first update of the frame
empty Start ()
{
rotationAboutX = transform.localEulerAngles.x;
rotationAboutY = transform.localEulerAngles.y;
}

void Update ()
{
rotationAboutX - = Input.GetAxis ("Mouse Y") * ySensitivity;
rotationAboutY + = Input.GetAxis ("Mouse X") * xSensitivity;

rotationAboutX = Mathf.Clamp (rotationAboutX, downLimit, upLimit);
}

// Adjust the position of the camera.
void LateUpdate ()
{
Direction Vector3 = new Vector3 (0.0f, 0.0f, -maxDistanceFromPlayer);
Quaternion rotation = Quaternion.Euler (rotationAboutX, rotationAboutY, 0);
// Point to look in the runitme.
Vector3 focus = player.position + transform.TransformDirection (offset);

// Rotate the vector according to the mouse entries.
transform.position = focus + rotation * direction;

transform.LookAt (focus);
}
}

It only shivers if the offset is not zero. Otherwise it's good.