#StackBounty: #unity #c# #python How to make Unity' hidden dot folders visible?

Bounty: 50

My problem is that I have some plugin files inside a folder ".lib" that I need to read in my script, I keep getting errors because the script can’t find the ".lib" folder.
Apparently unity hides folders that starts with a dot.
is there a way around this ?.

Edit :
I’m running a python script using ironpyton, I got some packages in the project, the error happens when it gets to import ‘python package name’ in the python script, due to the missing folder, I can clearly see the folder ‘.lib’ in the file explorer but completely invisible in the project. to clarify things I didn’t set the path manually, one of the python packages causes this error when it can’t find the folder.

the error I got in the console :

OSException: cannot load library C:UsersSaiDocumentsWorkUnityUnity-Python-Demo-masterAssetsStreamingAssetsLibsite-packagesnumpy.libslibopenblas.SVHFG5YE3RK3Z27NVFUDAPL2O3W6IMXW.gfortran-win32.dll

This is my code :

        var engine = Python.CreateEngine();
        ICollection<string> searchPaths = engine.GetSearchPaths();
#if UNITY_STANDALONE_WIN
        searchPaths.Add(Application.dataPath);
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Lib");
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Libsite-packages");
        engine.SetSearchPaths(searchPaths);
        dynamic py = engine.ExecuteFile(Application.dataPath + @"StreamingAssets" + @"Pythonpt.py");
        test = py.CTScan("Codemaker"); //"Codemaker"

My python script :

from time import sleep
from System.Collections.Generic import *

import scipy



class CTScan():
    COLORS = {
        "sick": "rgb(176,55,55)",
        "healthy": "rgb(128,128,128)"
    }

    OPACITY = {
        "sick": 0.3,
        "healthy": 0.2
    }

Folder is visible in the file explorer

Same folder not visible from inside the project


Get this bounty!!!

#StackBounty: #unity #c# #python How to make Unity' hidden dot folders visible?

Bounty: 50

My problem is that I have some plugin files inside a folder ".lib" that I need to read in my script, I keep getting errors because the script can’t find the ".lib" folder.
Apparently unity hides folders that starts with a dot.
is there a way around this ?.

Edit :
I’m running a python script using ironpyton, I got some packages in the project, the error happens when it gets to import ‘python package name’ in the python script, due to the missing folder, I can clearly see the folder ‘.lib’ in the file explorer but completely invisible in the project. to clarify things I didn’t set the path manually, one of the python packages causes this error when it can’t find the folder.

the error I got in the console :

OSException: cannot load library C:UsersSaiDocumentsWorkUnityUnity-Python-Demo-masterAssetsStreamingAssetsLibsite-packagesnumpy.libslibopenblas.SVHFG5YE3RK3Z27NVFUDAPL2O3W6IMXW.gfortran-win32.dll

This is my code :

        var engine = Python.CreateEngine();
        ICollection<string> searchPaths = engine.GetSearchPaths();
#if UNITY_STANDALONE_WIN
        searchPaths.Add(Application.dataPath);
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Lib");
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Libsite-packages");
        engine.SetSearchPaths(searchPaths);
        dynamic py = engine.ExecuteFile(Application.dataPath + @"StreamingAssets" + @"Pythonpt.py");
        test = py.CTScan("Codemaker"); //"Codemaker"

My python script :

from time import sleep
from System.Collections.Generic import *

import scipy



class CTScan():
    COLORS = {
        "sick": "rgb(176,55,55)",
        "healthy": "rgb(128,128,128)"
    }

    OPACITY = {
        "sick": 0.3,
        "healthy": 0.2
    }

Folder is visible in the file explorer

Same folder not visible from inside the project


Get this bounty!!!

#StackBounty: #unity #c# #python How to make Unity' hidden dot folders visible?

Bounty: 50

My problem is that I have some plugin files inside a folder ".lib" that I need to read in my script, I keep getting errors because the script can’t find the ".lib" folder.
Apparently unity hides folders that starts with a dot.
is there a way around this ?.

Edit :
I’m running a python script using ironpyton, I got some packages in the project, the error happens when it gets to import ‘python package name’ in the python script, due to the missing folder, I can clearly see the folder ‘.lib’ in the file explorer but completely invisible in the project. to clarify things I didn’t set the path manually, one of the python packages causes this error when it can’t find the folder.

the error I got in the console :

OSException: cannot load library C:UsersSaiDocumentsWorkUnityUnity-Python-Demo-masterAssetsStreamingAssetsLibsite-packagesnumpy.libslibopenblas.SVHFG5YE3RK3Z27NVFUDAPL2O3W6IMXW.gfortran-win32.dll

This is my code :

        var engine = Python.CreateEngine();
        ICollection<string> searchPaths = engine.GetSearchPaths();
#if UNITY_STANDALONE_WIN
        searchPaths.Add(Application.dataPath);
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Lib");
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Libsite-packages");
        engine.SetSearchPaths(searchPaths);
        dynamic py = engine.ExecuteFile(Application.dataPath + @"StreamingAssets" + @"Pythonpt.py");
        test = py.CTScan("Codemaker"); //"Codemaker"

My python script :

from time import sleep
from System.Collections.Generic import *

import scipy



class CTScan():
    COLORS = {
        "sick": "rgb(176,55,55)",
        "healthy": "rgb(128,128,128)"
    }

    OPACITY = {
        "sick": 0.3,
        "healthy": 0.2
    }

Folder is visible in the file explorer

Same folder not visible from inside the project


Get this bounty!!!

#StackBounty: #unity #c# #python How to make Unity' hidden dot folders visible?

Bounty: 50

My problem is that I have some plugin files inside a folder ".lib" that I need to read in my script, I keep getting errors because the script can’t find the ".lib" folder.
Apparently unity hides folders that starts with a dot.
is there a way around this ?.

Edit :
I’m running a python script using ironpyton, I got some packages in the project, the error happens when it gets to import ‘python package name’ in the python script, due to the missing folder, I can clearly see the folder ‘.lib’ in the file explorer but completely invisible in the project. to clarify things I didn’t set the path manually, one of the python packages causes this error when it can’t find the folder.

the error I got in the console :

OSException: cannot load library C:UsersSaiDocumentsWorkUnityUnity-Python-Demo-masterAssetsStreamingAssetsLibsite-packagesnumpy.libslibopenblas.SVHFG5YE3RK3Z27NVFUDAPL2O3W6IMXW.gfortran-win32.dll

This is my code :

        var engine = Python.CreateEngine();
        ICollection<string> searchPaths = engine.GetSearchPaths();
#if UNITY_STANDALONE_WIN
        searchPaths.Add(Application.dataPath);
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Lib");
        searchPaths.Add(Application.dataPath + @"StreamingAssets" + @"Libsite-packages");
        engine.SetSearchPaths(searchPaths);
        dynamic py = engine.ExecuteFile(Application.dataPath + @"StreamingAssets" + @"Pythonpt.py");
        test = py.CTScan("Codemaker"); //"Codemaker"

My python script :

from time import sleep
from System.Collections.Generic import *

import scipy



class CTScan():
    COLORS = {
        "sick": "rgb(176,55,55)",
        "healthy": "rgb(128,128,128)"
    }

    OPACITY = {
        "sick": 0.3,
        "healthy": 0.2
    }

Folder is visible in the file explorer

Same folder not visible from inside the project


Get this bounty!!!

#StackBounty: #unity #c# #android #xml How can I use an inherited Activity in C#?

Bounty: 250

I am using Unity. I want to set the status bar to be permanent in opaque black. I set Start in Full Screen Mode in the Player Settings to false, and call ShowStatusBar from the following code, and life is good:

using System;
using UnityEngine;

public static class AndroidUtility
{
    private const int MinStatusBarColorApi = 21;
    private const int SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN = 0x00000400;
    private const int BlackColor = 0x00000000;

    private static AndroidJavaObject activity;

    public static void ShowStatusBar(int color = BlackColor)
    {
        RunOnUiThread(() =>
            {
                using (var window = Window)
                {
                    window.Call("clearFlags", SYSTEM_UI_FLAG_LAYOUT_FULLSCREEN);
                    if (GetApi() >= MinStatusBarColorApi)
                    {
                        window.Call("setStatusBarColor", color);
                    }
                    else if (color != default)
                    {
                        Debug.LogWarning("Changing the status bar color is not supported on Android API lower than Lollipop.");
                    }
                }
            });
    }

    private static void RunOnUiThread(Action action)
    {
        Activity.Call("runOnUiThread", new AndroidJavaRunnable(action));
    }

    private static AndroidJavaObject Activity
    {
        get
        {
            if (activity == null)
            {
                var unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
                activity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
            }
            return activity;
        }
    }

    private static AndroidJavaObject Window
    {
        get
        {
            return Activity.Call<AndroidJavaObject>("getWindow");
        }
    }

    private static int GetApi()
    {
        using (var version = new AndroidJavaClass("android.os.Build$VERSION"))
        {
            return version.GetStatic<int>("SDK_INT");
        }
    }
}

I then added a plugin (Firebase Messaging) which uses a custom AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" package="com.mypackage" android:versionCode="1" android:versionName="1.0">
  <application android:label="@string/app_name" android:icon="@drawable/app_icon">
    <!-- The MessagingUnityPlayerActivity is a class that extends
         UnityPlayerActivity to work around a known issue when receiving
         notification data payloads in the background. -->
    <activity android:name="com.google.firebase.MessagingUnityPlayerActivity" android:configChanges="fontScale|keyboard|keyboardHidden|locale|mnc|mcc|navigation|orientation|screenLayout|screenSize|smallestScreenSize|uiMode|touchscreen">
      <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>
      <meta-data android:name="unityplayer.UnityActivity" android:value="true" />
    </activity>
    <service android:name="com.google.firebase.messaging.MessageForwardingService" android:exported="false" />
  </application>
</manifest>

My AndroidUtility class no longer works! The status bar just shows up as a solid white bar. I suspect this is because I am still referencing the default UnityPlayerActivity, when I should be referencing the MessagingUnityPlayerActivity? I have tried changing the AndroidJavaClass to com.google.firebase.MessagingUnityPlayerActivity, (among other things,) but that just makes the status bar go away completely.

How can I adjust the AndroidUtility class and AndroidManifest to work with the inherited AndroidManifest.xml?

(Also, the Android Back Button no longer does anything.)


Get this bounty!!!

#StackBounty: #unity #physics #vehicle Custom steering system in Unity for braking and sliding

Bounty: 50

I am developing a game where the player controls a vehicle. But instead of using a first person view, the camera is top-down and orthographic.

I tried using Unity’s wheel collider system. While that would work just fine for a first-person view (e.g. a traditional racing game), the controls don’t work well with a top-down view (e.g. think Micromachines on the NES). The reason, I think, is that turning and acceleration need to be much more responsive with a top-down view than with a real vehicle steering simulation. You’re not racing on a track. When viewing from top-down, the vehicle needs to accelerate and turn much more quickly than a “real” vehicle ever could.

I have implemented my own steering system based on Ackermann steering, which works fine. What I am missing is a good simulation of friction and skidding. For instance, I would like my vehicle to skid and slide if the user brakes while turning.

I don’t have a background in physics or mechanics so I am not sure where to start. Can someone give me some pointers?

Here is the code I have so far for simple steering:

void Move() {
    bool isLeft = Input.GetKey (KeyCode.A);
    bool isRight = Input.GetKey (KeyCode.D);
    bool isUp = Input.GetKey (KeyCode.W);
    bool isDown = Input.GetKey (KeyCode.S);

    turn = 0;

    acceleration = 0;
    speed *= friction;

    if (isReverse != isDown && (isUp || isDown)) {
        speed *= reverseDamping;
    }

    turn += isLeft ? (int) (-angleVel * speed) : 0;
    turn += isRight ? (int) (angleVel * speed) : 0;

    acceleration += isUp ? Time.deltaTime : 0;
    acceleration += isDown ? -Time.deltaTime : 0;
    speed += acceleration;

    transform.Rotate (0, turn, 0);
    transform.Translate (Vector3.forward * speed, Space.Self);

    isReverse = isDown;
}


Get this bounty!!!

#StackBounty: #unity #textures Unity: Exporting Game creates Texture Glitches

Bounty: 50

In the editor the textures are fine, however upon exporting I’m constantly faced with glitches like these:

enter image description here

I mainly use the Built-in Standard Specular Shader and the texture that gets glitched is always the Detail Texture. When re-exporting the game multiple times the texture gets glitched exactly the same way in the same spots.

This has happened in pretty much every scene so far.

enter image description here


Get this bounty!!!

#StackBounty: #unity #steamworks SteamWorks.Net for unity and inviting a friend to a multiplayer game

Bounty: 300

I’m trying to send an invitation to a steam friend and have it that when he accepts I create a PUN 2 room for both players and they can start their match. So far I’ve done this :

 protected Steamworks.Callback<GameRichPresenceJoinRequested_t> m_GameRichPresenceJoinRequested;


private void OnEnable()
{
    m_GameRichPresenceJoinRequested = Callback<GameRichPresenceJoinRequested_t>.Create(OnGameRichPresenceJoinRequested);
}


public void InviteFriend()
{

    SteamFriends.InviteUserToGame(steamFriendData.friendSteamId, "");
}

private void OnGameRichPresenceJoinRequested(GameRichPresenceJoinRequested_t pCallback)
{
     Debug.Log(pCallback.m_rgchConnect);
    Debug.Log("<color=green>Friend accepted the invite</color> ");
}

The invite is being sent to the correct friend and when he accepts it launches the game but I get no callback from that and thus have no way to place them in a room. What am I doing wrong ?


Get this bounty!!!

#StackBounty: #unity #c# #2d #animation #movement 8-way 2D top down movement (diagonal) idle animation issues

Bounty: 50

Background

I am working on animations for 8-way movement for my character and have done the 8 directional running animations using a blend tree.

Now I need to do the same for the idle animations.

When the player stops moving, the correct idle animation should play.

For example, if they move right and let go of the ‘A’ button, then the idle animation of the player facing right is played.


Problem

I have done 4/8 directions (Up, Left, Right & Down), my problem is with the diagonals.

e.g if the player lets go of the ‘W’ and ‘D’ keys then the idle animation of the player facing the Upper Right corner should be played.

I can’t get this to work though.

My blend tree for the animations:

enter image description here

I realize that it’s because the two keys (Whether W+D, S+D, A+S, or W+A) are let go at different times, and with the system I have currently, the player has to let go of any of those two key combinations at exactly the same time to successfully play the right diagonal animation.


Tl;Dr:

How do I accomplish these post-movement idle animations when my current system relies on the player releasing the correct keys simultaneously?

Is there a system for this, add a tiny bit of input lag or map keys to something?

Code:

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

public class PlayerMovement : MonoBehaviour
{
    [SerializeField] private Transform pfDashEffect;

    public Animator animator;

    public LayerMask layerMask;

    Vector2 movement;

    public float speed = 10f;
    public float dashDistance = 100f;
    private Vector3 lastMoveDir;

    private float MoveX;
    private float MoveY;

    private void Update()
    {
        // Input
        movement.x = Input.GetAxisRaw("Horizontal");
        movement.y = Input.GetAxisRaw("Vertical");

        animator.SetFloat("Horizontal", movement.x);
        animator.SetFloat("Vertical", movement.y);
        animator.SetFloat("Speed", movement.sqrMagnitude);

        Move();
        Dash();

    }

    private void FixedUpdate()
    {
        PlayerAbilities.Dash();
    }

    private void Move()
    {
        MoveX = 0f;
        MoveY = 0f;

        if (Input.GetKey(KeyCode.W))
        {
            MoveY = +1f;
        }
        if (Input.GetKey(KeyCode.A))
        {
            MoveX = -1f;
        }
        if (Input.GetKey(KeyCode.S))
        {
            MoveY = -1f;
        }
        if (Input.GetKey(KeyCode.D))
        {
            MoveX = +1f;
        }

        bool isIdle = MoveX == 0 && MoveY == 0;
        if (isIdle)
        {
            // Play idle animation with the lastMoveDir so that the idle animation plays in the right rotation (left, right, up, down)
        }
        else
        {
            Vector3 moveDir = new Vector3(MoveX, MoveY).normalized;

            if (TryMove(moveDir, speed * Time.deltaTime))
            {
                // Play walking
                animator.SetFloat("Horizontal", movement.x);
                animator.SetFloat("Vertical", movement.y);
                animator.SetFloat("Speed", movement.sqrMagnitude);
            }
            else
            {
                // Play idle
                animator.SetFloat("Speed", 0);
            }
        }
    }

    private bool CanMove(Vector3 dir, float distance)
    {
        return Physics2D.Raycast(transform.position, dir, distance, layerMask).collider == null;
    }

    private bool TryMove(Vector3 baseMoveDir, float distance)
    {
        Vector3 moveDir = baseMoveDir;

        bool canMove = CanMove(moveDir, distance);
        if (!canMove)
        {
            // Cannot move diagonally
            moveDir = new Vector3(baseMoveDir.x, 0f).normalized;
            canMove = moveDir.x != 0f && CanMove(moveDir, distance);
            if (!canMove)
            {
                // Cannot move horizontally
                moveDir = new Vector3(0f, baseMoveDir.y).normalized;
                canMove = moveDir.y != 0f && CanMove(moveDir, distance);
            }
        }

        if (canMove)
        {
            lastMoveDir = moveDir;
            // Play walking animation with the moveDir so that the idle animation plays in the right rotation (left, right, up, down)
           // storeLastDirection(new Vector3(MoveX, MoveY));

            animator.SetFloat("LastMoveVertical", lastMoveDir.y);
            animator.SetFloat("LastMoveHorizontal", lastMoveDir.x);
            transform.position += moveDir * distance;
            return true;
        }
        else
        {
            return fase;
        }
    }

    private void Dash()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            Vector3 beforeDashPosition = transform.position;
            if(TryMove(lastMoveDir, dashDistance))
            {
                Transform dashEffectTransform = Instantiate(pfDashEffect, beforeDashPosition, Quaternion.identity);
                dashEffectTransform.eulerAngles = new Vector3(0, 0, GetAngleFromVectorFloat(lastMoveDir));
                float dashEffectWidth = 5;
                dashEffectTransform.localScale = new Vector3(dashDistance / dashEffectWidth, 1f, 1f);
            }
        }
    }

    public static float GetAngleFromVectorFloat(Vector3 dir)
    {
        dir = dir.normalized;
        float n = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg;
        if (n < 0) n += 360;

        return n;
    }
}

At the moment I’m just storing the two x and y coordinates for my blend tree like this:

animator.SetFloat("LastMoveVertical", lastMoveDir.y);
animator.SetFloat("LastMoveHorizontal", lastMoveDir.x);

Which works well for the simple directions (North, East, South, West), just not the diagonal ones as the X/Y values change when each button is released. So if the player lets go of the W and 5 milliseconds later lets go of the D key, that’s enough for the value to change which then in turn doesn’t show the correct animation.


Get this bounty!!!