I am trying to identify the index of a game object in a list when i click on it. I can get this to work for simple list as in the example "objects" list. However I am trying to get it to work with the "itemDatabase" as defined by the class "Item" and has variable for game object. Any suggestions on how to do this would be appreciated.
using System.Collections;`enter code here`
using System.Collections.Generic;
using UnityEngine;
public class ItemDB : MonoBehaviour
{
public List- itemDatabase = new List
- ();
public List
objects;
Ray ray;
RaycastHit hit;
void Update()
{
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
if (Physics.Raycast(ray, out hit) && Input.GetMouseButtonDown(0))
{
for (int i = 0; i < itemDatabase .Count; i++)
{
if (hit.collider.gameObject == objects[i].gameObject)
{
Debug.Log ("Your cube's index in the array is: " + i.ToString());
}
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[System.Serializable]
public class Item
{
public string name;
public GameObject obj;
public Sprite mySprite;
}
↧
Identify index of game object on mouse click
↧
Why unity ads income suddenly dropped?
I released a game recently,Income has been relatively stable.But in February 7,income suddenly dropped,
It's been like this for the next few days.But the number of downloads is normal.
The first picture is income,the second is downloads.
![alt text][1]
![alt text][2]
[1]: /storage/temp/152699-qq图片20200212183018.png
[2]: /storage/temp/152700-qq图片20200212183813.png
↧
↧
liquid physics shader like "Splash canyon"
Hi, I want to make the water like this how can I achieved this:
https://apps.apple.com/us/app/splash-canyon-water-puzzles/id865685473
![alt text][1]
[1]: /storage/temp/152701-392x696bb.png
↧
Create default object in custom PropertyDrawer
When you mark class as [System.Serializable] unity will draw foldout in the inspector for fields of that class.
When you click on the foldout unity will create default serialized object of that type and display it with default values (for int will be 0 for example).
How to create this default object in your custom PropertyDrawer?
Isnt that SerializedProperty.objectReferenceValue ? but its of type UnityEngine.Object, while my class is not and without custom PropertyDrawer it works.
↧
Package Manager not loading in anything due to package error
Hello!
I'm new to Unity (using 2019.2.21f1) and having trouble with the package manager. When I open it up, it starts loading and then stops at some point without loading in anything. I get the error message
"Package Manager Window had an error while completing an operation: System.ArgumentException: JSON parse error: The document is empty."
Then after a bit it switches to
"Couldn't delete Packages/com.unity.textmeshpro/Tests because it's an immutable folder."
I have no idea why it can't load in the JSON data it apparently needs. I've tried reinstalling Unity and also deactivating the Windows Firewall since that seemed to fix similar issues for people but that didn't work either. Hope someone can help, thank you!
↧
↧
If more then 2 players join the Photon Server it gets glitchy?
So I'm testing the Photon Network and I have 2 clients open but when I open a third client, players are seen floating above the ground on the third client.
Why is that?
↧
Is it possible do define a LayerMask in scripts?
Hi
I want to define a layerMask without having to do it in the inspector, I want to do it in scripts.
Is this possible?
↧
IOS release, no show of any prefabs
in unity editor everything works fine.
heres some xcode debug output:
2020-02-11-[UIApplication setStatusBarOrientation:] and -[UIApplication setStatusBarOrientation:animated:] API have been deprecated on iOS 8.0 and are no-ops on iOS 13.0
[575:74944] [Common] _BSMachError: port 13d03; (os/kern) invalid capability (0x14) "Unable to insert COPY_SEND"
575:74944] Unbalanced calls to begin/end appearance transitions for .
(Filename: ./Runtime/Export/Debug/Debug.bindings.h Line: 35)
NullReferenceException: Object reference not set to an instance of an object.
at Tile..ctor (System.Int32 x, System.Int32 y) [0x00000] in <00000000000000000000000000000000>:0
at Board.SetupBoard () [0x00000] in <00000000000000000000000000000000>:0
(Filename: currently not available on il2cpp Line: -1)
2020-02-11 17:28:50
nw_socket_handle_socket_event [C2.1:3] Socket SO_ERROR [61: Connection refused]
..:75193] [BoringSSL]
nw_protocol_boringssl_handshake_negotiate_proceed(726) [0x111616f20] handshake failed at state 0
Connection 2: received failure notification
Connection 2: failed to connect 1:61, reason -1
Connection 2: encountered error(1:61)
Task .<1> HTTP load failed, 0/0 bytes (error code: -1004 [1:61])
..204] Task .<1> finished with error [-1004] Error Domain=NSURLErrorDomain Code=-1004 "Could not connect to the server." UserInfo={_kCF...rCodeKey=61, NSUnderlyingError=0x2837ba940 {Error Domain=kCFErrorDomainCFNetwork Code=-1004 "(null)" UserInfo={_kCFStreamErrorCodeKey=61, _kCFStreamErrorDomainKey=1}}, _NSURLErrorFailingURLSessionTaskErrorKey=LocalDataTask .<1>, _NSURLErrorRelatedURLSessionTaskErrorKey=(
"LocalDataTask .<1>"
), NSLocalizedDescription=Could not connect to the server., NSErrorFailingURLStringKey=https://config.uca.cloud.unity3d.com/, NSErrorFailingURLKey=https://config.uca.cloud.unity3d.com/, _kCFStreamErrorDomainKey=1}
nw_socket_handle_socket_event [C3.1:3] Socket SO_ERROR [61: Connection refused]
..
..204] [BoringSSL] nw_protocol_boringssl_handshake_negotiate_proceed(726) [0x1053e4bb0] handshake failed at state 0
↧
Unity Learn and Unity connect load as plain text on any browser, how to fix?
While the main Unity website (and all other websites) load fine, starting just today both the Unity Learn and Unity Connect pages load only as plain text in either Chrome (my default browser) or Internet Explorer.
I have spent hours now trying every solution I can find online -- checking firewall settings, extensions, deleting browser cache, hard reset, restart my entire dang computer. Nothing works. The main page for Unity Learn displays fine, but as soon as I go to any tutorials page to continue a tutorial *I was already working on* suddenly these pages no longer load properly.
Is this just an issue on Unity's side?
![alt text][1]
[1]: /storage/temp/152665-unityplaintext2.jpg
↧
↧
,models shuteter/ not showing in game
![alt text][1]
[1]: /storage/temp/152712-ad.jpg
Models Shutters/not showing correctly Its not a game i develop or somthing but i could not find the answer about unity3d games anywhere. old versions of the game worked fine but when the develop team moved to unity 2019 models not showing correctly you can see the bottom of it,![alt text][1]
↧
Why am I not able to get rid of texture backgrounds on my particles even though the images are png?
I've been trying all sorts of changes here and there to get rid of backgrounds to my particle textures but I simply can't find a good way to get rid of the square backgrounds for my normally small spherical particles alt text
here is a picture of the square particles i get. Thanks a lot
[1]: /storage/temp/152714-particles-background.png
↧
Unable to give Verizon feedback. What is Verizon wireless support number?
Verizon is the company that values the feedback provided by the customers and takes it very seriously. If the feedback is positive, then we try to outperform ourselves and if it is negative, then we introspect and better ourselves. However, if you’re unable to give feedback to us ,then all you need to do is contact [Verizon wireless support number][1] and they’ll guide you.
[1]: https://attcustomerservicephonenumber.com/verizon-wireless-customer-service/
↧
Rect Transform. Help!
Help! Tell me how to fit a custom rect transform in the unit to the sprite borders (so that the angle where the green arrow is where the red arrow is)? Dragging the mouse on each image for a very long time, maybe there is some way to do this automatically?
![alt text][1]
[1]: /storage/temp/152715-unity3.jpg
↧
↧
How to attach an object to another?
I’m making a mobile app where you play as a knight blocking arrows. I want the knight to be stuck in place but the shield can go across his head and to the side (depending where the player touches)
I figure the best way to do this is to have the shield as a seperate object that I attach to his hand and the hand will follow the shield. Are there any guides or resources on how to accomplish this as I am quite new to unity.
↧
Oculus Go - Game crashes on scene load (Unity)
Hi there.
So basically I have this app which has about 15 different scenes, they all work fine other than this one scene, which is recreating Pearl Harbour. The scene is fairly simple, but the OVR Profiler says I'm using 524MB of graphic memory (I'm assuming this is the issue and why my game is crashing when attempting to load this scene, as all other scenes work fine). The only problem is, when I remove a few of the other scenes, this scene loads fine. Am I using too many scenes?
The weird thing is, it works fine in the Unity Editor, and it actually worked perfectly on the Oculus Go device a few days ago, yet crashes now when attempting to load that Pearl Harbour scene.
Was wondering if anyone else had the same issue? Thanks
↧
OnTriggerEnter2D call function in other GameObject
Hello, I'm making a game where you're a little character moving through a guitar fret board, my goal right now is to be able to press an interact button and have it play the right note based on which fret you're in.
My idea is to have individual objects with a trigger box collider in each fret, and have OnTriggerEnter2D call a function in my character controller that sets a variable to a number so that later I can play the correct sound based on that number.
I would have this code in every object where fretNum is a different int for every individual one
void OnTriggerEnter2D (Collider2D collision)
{
CharacterController2D player = collision.GetComponent();
if(collision != null)
{
player.SetPos(fretNum);
}
}
and in my character controller I have
int pos;
public void SetPos(int currentPos)
{
currentPos = pos;
Debug.Log(pos);
}
But in my console it just prints out the number 0 no matter what value I set fretNum. It also prints twice, which I don't understand. Is there something I'm doing wrong? Is there a different way you would approach a situation like this?
Thanks in advance.
↧
How to check if object fully enters triger object.
I'm trying to only trigger a collision if i have fully entered a collision with every point of my player object or at least most points of my player object.
Thanks
↧
↧
unity character move inverse rotation joystick
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Playermovement : MonoBehaviour
{
public FixedTouchField touchField;
public FixedJoystick leftjoystick;
protected CharacterController characterController;
Vector3 Movedir = Vector3.zero;
public Rigidbody rb;
protected Animator animator;
protected float cameraangleY = 2f;
protected float cameraanglespeed = 2f;
protected float camerayposY;
protected float cameraposspeed = 2f;
public FixedJoystick rightjoystick;
public float rot;
public float rotspeed = 80f;
void Start()
{
rb = GetComponent();
characterController = GetComponent();
animator = GetComponent();
}
void Update()
{
rb.velocity = new Vector3(leftjoystick.Horizontal * 1f, 0, leftjoystick.Vertical * 1f);
if (leftjoystick.Horizontal != 0f || leftjoystick.Vertical != 0f)
{
animator.SetInteger("conditions", 1);
transform.rotation = Quaternion.LookRotation(rb.velocity);
}
else
{
animator.SetInteger("conditions", 0);
}
transform.rotation = Quaternion.AngleAxis(cameraangleY, Vector3.up);
cameraangleY += rightjoystick.Horizontal * cameraanglespeed ;
Camera.main.transform.position = transform.position + Quaternion.AngleAxis(cameraangleY, Vector3.up) * new Vector3(0, 3, -4);
Camera.main.transform.rotation = Quaternion.LookRotation(transform.position + Vector3.up * 2f - Camera.main.transform.position, Vector3.up);
}
}
↧
Total beginner trying to implement sound into Viking Village for first time
Hello, so I'm an absolute beginner when it comes to Unity or dealing with any sort of code. I'm following a YouTube tutorial to learn how to implement audio into Unity with Wwise using Viking Village as a starting point but have ran into some immediate issues. I wonder if someone here could help me...
The 2 errors I am getting are:
> Cameras missing! Different cameras are needed for different performance profiles. UnityEngine.Debug:LogError(Object). QualitySetup:OnEnable() (at Assets/Scripts/QualitySetup.cs:27)> UnassignedReferenceException: The variable manualController of ControlSwitch has not been assigned. You probably need to assign the manualController variable of the ControlSwitch script in the inspector. ControlSwitch.SetControllerState (System.Boolean useAutomaticControl) (at Assets/Scripts/ControlSwitch.cs:34) ControlSwitch.Awake () (at Assets/Scripts/ControlSwitch.cs:16)
Again I am an absolute beginner, I have no idea where to start to tackle these problems. Any help would be hugely appreciated.
I get the impression that this is because I am running Viking Village on a newer version of Unity - are there any other projects, perhaps slightly newer ones, that would allow me to avoid these issues and would also be suitable to replace the sound in?
Thank you.
↧
Have a problem with Automatically Generated Tiles - 3D
When automatically generates tiles, after a while there is something like a step and the cube hit it, but there isn't any kind of irregularity in the floor.
How can I fix it?
Here's video that explain what happen
https://drive.google.com/file/d/1DAHJKjgpI_RJY5T8KU5JRgXjypCw5IYQ/view?usp=sharing
↧