#archived-code-general

1 messages · Page 167 of 1

timid meteor
#

Quick question I am getting this error You probably need to add a Rigidbody to the game object "Pinky". Or your script needs to check if the component is attached before using it. UnityEngine.Rigidbody.get_velocity () (at <a019610f26d54349b269239d6f729022>:0) for a lot of items and was wondering if there was a way to ignore a bunch or objects in one area

#

The code that is producing this error is this ```private void OnTriggerEnter(Collider other)
{
Debug.Log("Hit");

    //hit.transform.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;

    If(other.gameObject.GetComponent<MyComponent>)

        var triggerObject = other.gameObject.GetComponent<Rigidbody>();
        triggerObject.velocity = Vector2.ClampMagnitude(triggerObject.velocity, SlowDownModifier); //slows down things here
}```
rigid island
#

wdym handle events ?

pure cliff
#

public method on child script.
parent has a ref to its child script, and calls child's public method inside its event trigger method

magic scarab
#

hi, I started to learn about compute shaders recently, and I cant figure out how to send an array from a c# script to a compute shader
basically I want to draw a sdf polygon using a compute shader, but controling the amount of points and its position from the c# script, does someone know how I could do that?

oblique narwhal
# timid meteor The code that is producing this error is this ```private void OnTriggerEnter(Col...

`
private void OnTriggerEnter(Collider other)
{
Debug.Log("Hit");

    //hit.transform.gameObject.GetComponent<Rigidbody>().velocity = Vector3.zero;

    If(other.gameObject.GetComponent<MyComponent>)

        var triggerObject = other.gameObject.GetComponent<Rigidbody>();

       if(triggerObject == null) return;   // <==== add this.

        triggerObject.velocity = Vector2.ClampMagnitude(triggerObject.velocity, SlowDownModifier); //slows down things here
}

`

oblique narwhal
# timid meteor Quick question I am getting this error ```You probably need to add a Rigidbody t...

Or another approach

`
private void OnTriggerEnter(Collider other)
{
Debug.Log("Hit");

    // your pasted code does not have a correct set of braces after this IF statement, 
   // I think this is a copy paste error ??? and the below line could be removed?
    If(other.gameObject.GetComponent<MyComponent>)

    if (other.gameObject.TryGetComponent<Rigidbody>(out var rigidbody))
   {
       rigidbody.velocity = Vector2.ClampMagnitude(rigidbody.velocity, SlowDownModifier);
   }

}

`

prime sinew
#

it keeps it in editor. doesnt keep it in build

night harness
#

Is there a better way to easily display debug text in scene other than Handles.Labels?

prime sinew
#

for that reason, you shouldnt really be using them to save values or modify them during runtime

#

they're not meant for that reason

lean sail
#

Json is quite easy, the code is quite literally a couple of lines

rancid sable
#

is there a way to write the following without using object? I tried having the value be Type but then it doesn't let me convert it to T

    public class NetworkPlayerInputValue<Type> : PlayerInputValue
    {
        public object value;
        public override T ReadValue<T>()
        {
            if(typeof(Type) != typeof(T))
                throw new System.Exception($"Type:({typeof(T).FullName}) is not valid for this action");
            return (T)value;
        }
    }
#

nvm I found a way of pushing object casting back to only at startup

night harness
#

I know you shouldn't ask to ask a question but is anyone savvy with Handles.Labels related stuff? Trying to wrap my head around them and have a few questions about how to use them in the way i want to

lean sail
#

you gotta also call some json serialize function with WriteAllText, you shouldnt need to use system.serializable

#

which you then write to file

patent tartan
#

so unity uses just c sharp like no modification right>?

lean sail
mossy valley
#

I am assigning a gameobject in inspector. When I go to another scene and come back to that scene, that script loses reference to that gameobject. Why? Nothing happens to that gameobject I am referencing. I don't destroy it or instantiate it. It always stays in scene.

lean sail
mossy valley
#

Play mode

#

I get 500 of these errors 😭

lean sail
#

put error pause on

mossy valley
#

Is it cuz I sometimes use await task.delay and scenes might change before that task is carried out?

#

So it stops everything else from working?

#

I tried using the cancellation token approach but I didn't understand how to do it.

lean sail
#

that could be one reason yes, although its not really possible for me to confirm this without seeing the code

#

what are you using await for even, ive rarely seen true needs for it in unity so far

mossy valley
#

Unity Services and For getting events to occur Step by step. Plus I use it to get delay before another task happens since it doesn't register if the next task requires the previous task to be complete.

#

I have replaced Await with invoking a function with delay in my other project since it is a better approach. Yet to do it in this project since the time constraint is really short and I have a lot of Awaits here 😭

real pulsar
#

hi guys,
my unity gets stuck for a few seconds

#

I'm sending email with a picture attatchment from unity
but when i send the email
how can i resolve this problem
this is my code

lean sail
rustic temple
#

heyy im trying to await sence loading how would i do that? i cant do await UnityEngine.SceneManagement.SceneManager.LoadSceneAsync("TheRift");

real pulsar
#

fixed it

mossy valley
#

Wait I realized that the gameobject with the script is not getting destroyed on load 😭 I dont even have the DontDestroyOnLoad on it and yet it stays. Wtf

#

Okay I realized that the gameobject was not getting destroyed since it had IAP Listener which was not supposed to get destroyed on load. Now it works.

prime sinew
rustic temple
#

ah ok thanks didnt know that was a method

prime sinew
#

You.. just used it though 🤷

prime sinew
#

Hey, don't crosspost. Stick to one channel

void bison
#

cool

hollow hound
#

Is there a way to make colliders "compound" without adding the rigidbody?

hollow hound
thin idol
#

!code

tawny elkBOT
#
Posting code

📃 Large Code Blocks
Large code blocks should be posted as links to services like:
https://gdl.space/, https://paste.ofcode.org/, https://hatebin.com/
https://paste.myst.rs/, https://hastebin.com/

📃 Inline Code
Surround code with three backquotes. Not quotation marks.
To get C# formatting the first line should only contain cs or csharp.
Add a comment with a line number if there is an error message.
```cs
// Your code here
```
Do not share screenshots of code unless requested.

patent tartan
thin idol
#

so it says i didnt fix the compiled errors is there any problems with this code ``` system.Collections;
using System.Collections.Generic;
using UnityEngine;

public class airdash : MonoBehaviour
{

airdash moveScript; 

public float Dashspeed;
public float Dashtime;


// Start is called before the first frame update
void Start()
{
    moveScript  =  GetComponent<ThirdPersonMovement>();
}

// Update is called once per frame
void Update()
{

    if(Input.GetMouseButtonDown(0))
    {
        StartCoroutine(Dash());
    }
    
}

IEnumerator Dash()
{
    float startTime = Time.time;

    while(Time.time < startTime + dashTime) 
    {
        movescript.controller.Move(moveScript.moveDir * dashSpeed * Time.deltaTime)

        yield return null;
    }
}

}

#

its used as a mid air dash

#

(ultrakill ripoff)

prime sinew
#

!ide

tawny elkBOT
#
💡 IDE Configuration

If your IDE is not autocompleting code
or underlining errors, please configure it:

Visual Studio (Installed via Unity Hub)
Visual Studio (Installed manually)

VS Code*
JetBrains Rider
Other/None

*VS Code's debugger plugin is unsupported.
We recommend using VS or Rider instead.

prime sinew
#

your mistake is a simple one, you're missing a ;

#

if your IDE is configured, it'll mark with a red underline

thin idol
thin idol
prime sinew
thin idol
prime sinew
#

then read the bot link

#

on IDE configuration

thin idol
prime sinew
#

after you configure, it should mark where you're missing a ;

thin idol
prime sinew
#

i'm assuming that's the only error

#

you never shared the error

still wasp
#

Anyone know how to play a sound on collision in unity? been trying to figure out for hours now, ive got a grenade that i want to explode on impact, but i cant figure out how to do sound when it explodes

thin idol
winged mortar
#

You are missing a ; somewhere

quartz folio
#

They need to configure their IDE, then they can figure it out

waxen loom
#

Hello, I've watched GMTK's video about First Unity game and Code Monkey's RE on this video, Code Monkey states that you shouldn't use Tag String but Tag Component (or 2 other way that he briefly mentions in the video), could someone explain me how to reference a gameObject into a prefab please?

thin idol
#

bye bye notepad

waxen loom
#

Should I make a thread? 🧵

waxen loom
#

Well...Thank you

thin idol
#

my clothes have a hole in them

#

so i would like a thread

waxen loom
#

Oh

thin idol
#

to fix them

waxen loom
#

Here buddy <3 ✨ 🧵✨

thin idol
waxen loom
#

50 $ Please.

waxen loom
thin idol
waxen loom
#

Oh okay

thin idol
#

runs awayy

waxen loom
#

._.

quartz folio
#

Also please stop jabbering, there is no off-topic on this server

waxen loom
#

It was some quick jabbering don't worry we'll stop, and okay I'll try to learn how to use serialized references from an object in the hierarchy to a prefab

#

Wow, it's actually there, but now my brain is fuming x(

thin idol
# waxen loom ._.

i changed it to visual coding and it still didnt show a red underline?

waxen loom
#

Visual Studio Code?

thin idol
waxen loom
#

Well, idk sorry

#

¯_(ツ)_/¯

#

Oh

#

Have you tried Visual Studio Community?

thin idol
waxen loom
#

Maybe on Visual Studio Code you haven't installed the plugin for C#

thin idol
#

thanks deotexh

waxen loom
#

You're welcome ^^ x)

#

If I'm not mistaking the picture is C++/C# with a pink background

#

Nvm it's not

thin idol
waxen loom
#

It's with a green background

#

References?

thin idol
#

WHAT DO I DO

#

a a a a a a a a

waxen loom
#

Sure buddy

thin aurora
#

Hi, you're better off asking this in #💻┃unity-talk . This channel is aimed at helping beginners with coding concepts related to Unity

mystic fox
#

Hi, is it possible to keep the search window in the new Unity Search to only 1 instance... everytime I do dependency find I get a new window and I have to chase them down to close them one by one.

prime mica
#

OK guys, I'm unsure where exactly to post this as I don't really know how to find the problem or solve it. I have a project using the Unity FPS Starter pack (with the controller). For some reason the player's mouse movement gets "stuck" randomly

#

as in it sticks and struggles to move

dusk apex
prime mica
#

No. I think I just fixed it though

#

the movement threshold in the controller cod was set to 0.01 so I just set it to 0.001

craggy forum
#

hey guys. if I use Resources.LoadAll in a static dictionary class it works fine, but when using Resources.Load in the same static dictionary, Unity quits silently - what am i missing?

thin aurora
craggy forum
#

This is the previous version and that one works perfectly, but it slows the app down when you have 1k+ scriptable objects around

#

And these functions describe roughly what i try to achieve

thin aurora
craggy forum
#

Thats difficult to debug. It could also be the case that you cannot "add" to a static dictionary, once it has been instantiated

frosty bramble
#

Could anybody tell me please how I could master Unity starting from scratch. Like I know that I need to watch tutorials but how can I actually master it (In the sense of knowing game design and being able to program without constantly looking up things on Google and Youtube)

craggy forum
#

I watched a lot of tutorials and started by modifying existing project templates

frosty bramble
craggy forum
#

besides that a programming course does not hurt 😉

frosty bramble
rocky helm
#

Hello. So basically, I am making meshes at runtime to mimic glass shattering, but I have come across an odd problem. in this code snippet:

Vector3 p0 = vertices[0];
        Vector3 p1 = vertices[1];
        Vector3 p2 = vertices[2];
        Vector3 triangleNorm = (Vector3.Cross(p1-p0, p2-p0)).normalized; //Get the normal of the triangle | Some normals seem to have a value of 0,0,0
        if(triangleNorm == new Vector3(0,0,0)){
            Debug.Log(obj.transform.name);
            Debug.Log(p0); //not 0,0,0
            Debug.Log(p1); //not 0,0,0
            Debug.Log(p2); //not 0,0,0
            Debug.Log((Vector3.Cross(p1-p0, p2-p0)) == new Vector3(0,0,0)); //Always true
        } //All the y-axis are zero tho since that's what they are supposed to be for me

There are some triangles which have the normal be 0,0,0 after the calculation what, in return, breaks the mesh. It might be that the calculations for getting the normal are wrong, but I think it is correct? I know this is most likely not enough information to help me, but I don't quite know what else to give you except for a couple of the logs so feel free to ask me for anything more (these are p0, p1 and p2 in order without the Y axis since it is always 0): 0.010497 -0.002478973 & 0.011 -0.006 & 0.01098285 -0.002593712

late lion
#

But if you know all the vertices have 0 y position, then you already know the normal.

rocky helm
#

The y position should stay 0 always, but because they are in a local orientation

rocky helm
late lion
#

So the local normal of the mesh is always up. Then the world normal is the rotation of the object * Vector3.up.

Vector3 localNormal = Vector3.up;
Vector3 worldNormal = transform.rotation * localNormal;
rocky helm
#

holy jesus of macaroni, it works!

abstract cypress
#

Does anyone know if there is a data structure that allows accessing variables as easy as with static classes with static variables but also makes it dynamically extendable? I've tried just using static dictionaries with objects but accessing them is tedious as I need to cast each value everytime

steady moat
abstract cypress
humble void
#

I have an issue with 2 tiles of noise not aligning. Could it be this small line in the center that causes the issue?

abstract cypress
humble void
#
float[,] GeneratePerlinMatrix()
    {
        float[,] Noisemap = new float[resolution, resolution];
        
        for (int a = 0; a < resolution; a++)
        {
            for (int b = 0; b < resolution; b++)
            {
                float xSample = ((float)a / (resolution - 1) * ChunkSize + xOffset) * NoiseFrequency;
                float zSample = ((float)b / (resolution - 1) * ChunkSize + zOffset) * NoiseFrequency;
                
                Noisemap[a, b] = Mathf.PerlinNoise(xSample, zSample);
                samplePos[a, b] = new Vector3(xSample, 0, zSample);
            }
        }

        return(Noisemap);
    }

    void ConvertNmapToTerrain(float[,] noisemap)
    {
        if (currentTerrain == null)
        {
            TerrainData terrainData = new TerrainData();
            terrainData.heightmapResolution = resolution;
            terrainData.size = new Vector3(ChunkSize, HeightAmplifier, ChunkSize);
            terrainData.SetHeights(0, 0, noisemap);

            //Generate the terrain
            GameObject chunk = Terrain.CreateTerrainGameObject(terrainData);
            chunk.transform.position = new Vector3(xOffset, 0, zOffset);
            currentTerrain = chunk;
        }
        else
        {
            currentTerrain.GetComponent<Terrain>().terrainData.SetHeights(0, 0, noisemap);
            currentTerrain.transform.position = new Vector3(xOffset, 0, zOffset);
        }
    }
abstract cypress
#

Is the chunk size equal to the heightmap resolution?

humble void
#

It is not, ChunkSize is 100 and resolution is 129, however making them equal doesn't fix the problem sadly

#

I had another script calculate the heightmap in the exact same way and it worked, but that script was really bad and broke all the time so I am rewriting, but for some reason, the same approach doesn't work anymore

#

This is the old code, very messy as I said

float pointX = ((float)a / (resolution - 1) * TileSize + xOffset) * NoiseFrequency;
float pointZ = ((float)b / (resolution - 1) * TileSize + zOffset) * NoiseFrequency;

if (LayerCount == 1) //Exception for a single layer, as below code can only handle >1
  {
      Tile[a, b] += Mathf.PerlinNoise(pointX * DetailBaseValue, pointZ * DetailBaseValue) * ImpactBaseValue;
  }
patent tartan
#

Should i just learn C# before anything else about unity

humble void
#

No, learn both at the same time

patent tartan
#

like how

#

just try unity

humble void
#

Watch brackeys

patent tartan
#

ok.

humble void
rocky helm
#

If I have a Vector3 point in local coordinates, that is relative to a transform and is on the same plane as the right and up vector of the transform, then how could I translate the Vector3 point to be a Vector2 point on that plane? I have looked into planes in the api, but only found how to put the Vector3 point on the plane (as a Vector3 still), not how to translate it to a Vector2. Maybe something like Transform.InverseTransformPoint is what I am looking for, but I am a little confused about what exactly it does and if it does the right thing.

rain minnow
# patent tartan ok.

I wouldn't recommend brackeys only bc most of their tutorials are random one-offs; they don't follow an inherent pattern of learning concepts

I'd watch/read a beginner c# or fundamentals course and check the pinned tabs from #💻┃code-beginner

somber nacelle
rocky helm
#

I want to treat the right vector as the x and the up vector as the y

#

And get local coordinates of that point, but in 2d

rocky helm
somber nacelle
#

ah yeah, i had that backwards. still not exactly what you've described though

rocky helm
somber nacelle
#

local coordinates are relative to the object's position and rotation. i'm also not entirely getting what you are trying to do here. you explain it as if the plane is relative to the transform's up and right axes, which would make local coordinates with the Z axis dropped coordinates on that plane, but then you say it isn't?

rocky helm
somber nacelle
#

the X axis is the horizontal axis, if that is what you mean

rocky helm
somber nacelle
#

wtf do you mean by "towards the transforms right vector"

rocky helm
#

or is the x axis relative to smth else

somber nacelle
#

the X axis is the horizontal axis that runs left to right

rocky helm
#

so I guess yes it is that

somber nacelle
#

yes, transform.right is the vector that points along the right direction relative to the transform's rotation

rocky helm
#

Okay thanks!

rustic furnace
#

what is the difference between a class that is derived by monobehavior vs a non monobehavior class? Also, if I needed to get a variable from a non monobehavior class to a monobehavior class, how can I do that

quartz folio
#

There are many differences between Unity Objects and not, but it's kinda irrelevant without context

swift falcon
#

Hi, I'm having an issue with my gun in a 3d fps shooter game im making. Basically when is shoot the target it registers as a hit and gets confirmed with a debug.log statement but after a certain distance (2 or 3 meters away) the shots stop getting registered and the target doesnt take damage. I've tried plying around with the max distance value and some others but i can't seem to find the solution. Any help would be appreciated.

#

i can send the relevant scripts to whoever wants to help

rustic furnace
#

I don't know how to get the variables from the public class

#

getComponent<2> doesn't seem to work on 3

#

in void shootSpell, last line

quartz folio
#

GetComponent<SpellSlots>().spells

rocky helm
#

Oh wait I'm a dumbass I forgot what I even wanted to get to in the beginning. So, since the vertices positions are not relative to the transforms rotation, but rather are in their own "coordinate space", then how can I translate the vertices to be a Vector2 with the x being how far on the transform.right the point is and y being how far on the transform.up the point is?

quartz folio
#

Object space is the same as local space. transform.right is normalized though so it's ignoring scale

rocky helm
swift falcon
rustic furnace
#

I need to find the stats of the equipped spell

quartz folio
rustic furnace
#

I get this error and I don't know what to do to fix it

quartz folio
#

Your equipped spell is a gameobject, it has no connection to the spell stats instance

#

afaik it's literally just being referenced by spell stats and SpellSlots.equippedSpell and nothing else

rustic furnace
#

so how could I declare the stats in a way so that I can access them?

rocky helm
quartz folio
quartz folio
#

transform.up is in world space

#

it's nonsensical to add that to something that is in local space and expect anything meaningful to occur

autumn gorge
#

In my game what you do is you make like a phone, laptop, etc and you get money by people buying your product. but I don’t know how to make it so it is based on how expensive it is and what the specs are. Here is a example for what I want it to be like just it is based on specs and price https://youtu.be/ViUf0e7DMKM 3:24-4:04 top right where it says finale and units. If you could point me to a tutorial or docs or what I should do to achieve that system. Thank you

I hope you guys find this Game Dev Tycoon full game walkthrough playthrough gameplay no commentary video useful.Leave a like and share with your friends if you can ;) .Soon I'll be uploading some new videos about more games.

★Links★
Secondary channel: https://www.youtube.com/channel/UCVM9bpt-sIwXP2xJ9n7v3UA
https://steamcommunity.com/id/fullthr...

▶ Play video
rocky helm
terse garnet
#

Guys, I want to implement a transport mechanic to my character at a fixed distance but the angle according to the position of my mouse, I'm having trouble taking this angle and defining a Vector3

#

this is my current code, for now it is teleporting to a distance always ahead in x, how can I modify to take the angle of the mouse?

primal wind
quartz folio
#

But that doesn't take into account that transform.right has a world space magnitude of 1, so if your object is scaled it will be incorrect.
You can however just multiply the point by the transform's lossyScale and the x coordinate would then be the right magnitude

terse garnet
#

got it

ocean elk
#

Hey! I'm optimizing my game now. When I change display resolution on Android device in script with Screen.SetResolution GPU processing time reducing. Does it mean that I have issues with fill rate?

rocky helm
#

What is mesh.bounds.center relative to? the transforms position?

quartz folio
#

Everything in mesh is in object space, which is the same as local space

#

I don't really know how to help you understand the diffierent spaces, I am making a vector guide but it's got a lot of work to do before it can really cater for most things.

late lion
# ocean elk Hey! I'm optimizing my game now. When I change display resolution on Android dev...

That tells you that you are bottlenecked by the GPU. Which means that even if you optimized scripts, physics, or anything on the CPU, you wouldn't see any performance improvements (unless you're also running into power or thermal limits)
While your fillrate might be the biggest culprit, everything the GPU is doing is contributing to the bottleneck. Any optimization on the GPU will improve your frame rate.

ocean elk
late lion
#

URP/Lit is a complicated PBR shader. For mobile, you should use URP/Simple Lit

ocean elk
gray mural
#

is there a method that is called just with [ExecuteAlways] attribute?

gray mural
# ashen yoke xy problem

is there a method that is called just if [ExecuteAlways] attribute reffers to the whole class?

ashen yoke
#

explain what you are trying to achieve

gray mural
#

I probably want someone to answer my question

ashen yoke
#

so far you are asking a weird question which indicates you are attempting to solve something the wrong way

gray mural
#

so probably I want to know if there is a method like Start, but that is called when Edit mode is entered, not Game mode

ashen yoke
#

you can hook into EditorApplication.playModeStateChanged

#

you can use Application.isPlaying

#

in start, awake

#

you can extract your own bool from playModeStateChanged

#

and use it globally

gray mural
#

well, start and awake are just called when play mode is entered, so Application.isPlaying doesn't make sense here

ashen yoke
#

wrong

gray mural
#

putting it in Update makes sense

gray mural
#

so yes

#

it works as OnApplicationQuit with ExecuteAlwaysAttribute

ashen yoke
#

it is called when domain is reloaded

#

awake is called on everything

#

all prefabs all components

#

if you have a prefab with execute always and domain is reloaded awake will be called on it

#

if you have domain reload disabled it wont be called when you exit playmode

gray mural
#

OnEnable is called though

#

and thank you for your help 🙂

steady moat
#

However, because we do not know what you re trying to achieve, we cannot suggest you the best approach

gray mural
steady moat
#

Because, you know, testing is made with a goal.

gray mural
ashen yoke
#

Start and Awake called when - loading unity, dropping prefab into the scene in editor, loading that scene in editor, opening that prefab for editing, creating prefab variant, opening prefab variant,

steady moat
#

You might want to use a custom inspector ?

gray mural
gray mural
steady moat
ashen yoke
#

thank you so much, @steady moat thank you too

#

it seems im not worthy to be answered

#

at least Simferoce is

steady moat
#

lol

#

I feel you.

gray mural
steady moat
#

He has been asking you to explain what you were attempting to do.

#

And you just straight up said no and continue to ask question.

gray mural
#

where?

#

"xy problem"?

steady moat
gray mural
#

well, they have already solved my problem

#

I mean, context doesn't matter so much here

#

I am just testing things

#

serializing Type is already another problem

ashen yoke
#

that is a simple one

#

attach attribute with id to types you want serialized

#

resolve using that id

gray mural
ashen yoke
#

yes i understand what you said

gray mural
#

I see, I haven't understand what you have said though. Maybe you could explain it, please?

#

is there a documentation for this?

ashen yoke
#

no, there are libraries on github that do it

#

or you can do it yourself

gray mural
#

I haven't said that I need a library

ashen yoke
#

same principle attach attribute, use that attribute to resolve the type

gray mural
#

the type is always an enum

#

but this enum can have a different name

ashen yoke
#

if you cant attach directly because the type is in another assembly you add it to a LUT

gray mural
#

the problem is that enum isn't an object

ashen yoke
#

type is always an enum?

#

share code

gray mural
#
//
optionsEnum = typeof(LevelDiff); // public enum LevelDiff { ... };
#

this is how I do it with a specific enum

#

but I want to be able to do it in the inspector

#

so that I can chose whatever enum I want

#

that exists somewhere in the script

#

it will be actually perfect if I could do it by chosing public type from script from dragged object

#

(as it's done in Events)

#

I will have to do a research on that actually

ashen yoke
#

yep same thing i said earlier

#

attach attribute with id

#

resolve using that id

#

you can technically use anything as id, like the type name

#

but id is reliable, name isnt

#
[SerializedTypeId("someguid")
class Foo
{
}

    [System.Serializable]
    public class SerializedType
    {
        public Type type
        {
            get
            {
                if(_type == null)
                  _type = SerializedTypeResolver.GetType(_guid);
                return _type;
            }
        }
        Type _type;
        [SerializeField] string _guid;
    }

static class SerializedTypeResolver
{
    Dictionary<string, Type> types;
    static SerializedTypeResolver()
    {
        // collect all types with SerializedTypeId
    }
    public static Type GetType(string id) => types[id];
}

class SerializedTypePropertyDrawer : PropertyDrawer
{
      // draw dropdown selector for all types with id attached
}
#

in simple terms

gray mural
#

it's even easier than finding specific attribute then

ashen yoke
#

yeah and how will you serialize it

civic locust
civic locust
#

thumbnail pretty pog, ill have a look now

gray mural
# ashen yoke yeah and how will you serialize it
[SerializeField] private string optionsEnumName;

private Type[] allEnums;

private Type optionEnum;

//
// find all enums somewhere
//

private void OnValidate()
{
    optionsEnum = allEnums.First(w => w.FullName == optionsEnumName);
}
#

I will have to test it

#

also thank you for your help 😄

ashen yoke
gray mural
#

I see what you mean

ashen yoke
#

you renamed the enum, you move it, nest it, and all your serialized strings are broken

gray mural
#

yes, but the same can be with id

ashen yoke
#

no, id never changes

#

thats the idea

gray mural
#

if you rename an enum, you probably will rename the id too

ashen yoke
#

you never rename the id

gray mural
#

why?

ashen yoke
#

because its literally a guid string

gray mural
#

I think I shouldn't be "id123" for LevelDiff enum

ashen yoke
#

74945e6e-c72f-43eb-8312-f9c98563449d

#

this is the string in the attribute

#

a guid

lean sail
#

I doubt you'll ever look at a GUID x7x2h27js[...] and think you need to rename it

gray mural
#

how do you get this id?

ashen yoke
#

generate it any way you want

#

i have vs extension that inserts a new guid with ctrl+k+space

gray mural
#

I see

ashen yoke
#

you can use interactive window and Guid.New()

static matrix
#

Ok So
I am trying to have a looping level of some sorts
where after interacting with something you are warped back to the start and the level is replace, re-triggering the checks for all the various spawnables
however I think because the interactable is a child of the level, its applying the changes to the prefab?
I think?
I can also just try and have the interactable separate and just never move, that might work

gray mural
#

well, yes, it's reliable

#

thank you one more time

ashen yoke
#

its the same difference between unity asset databse and unreal one

#

i can only speak for ue4, but in it moving an asset would leave behind a "redirector" file

#

because assets dont have a guid attached to them

#

resolved by path

#

unity has .meta with guid

#

same as this attribute, meaning you can move assets anywhere

#

doesnt matter

#

even between projects

#

references will be preserved

lean sail
humble void
#

If you generate several layers of perlin noise with increasing frequency and decreasing impact and add the resulting height values together for every position, what is a good way to insure the values stay between 0 and 1 without flattening it to much (for example I tried dividing the heighrt values by the ammount of layers and using a sigmoid function but all made the terrain very flat and basicly destroyed the detail)

night lance
#

I'd say this is a code general question; Say I have a texture2D and a rect, how can I crop the texture2D, say the start is Vector2(120, 512) and the width is 1280 and height 1280. I'd need only those pixels. I've tried googling it, but I just don't get it.

ashen yoke
#

i advice to grab LibNoise and use it instead, or at least to get a reference for blending nodes

night lance
ashen yoke
#

scroll down

night lance
#

ah, i see, thank you

swift falcon
#

rb.AddForce(transform.up * jumpforce);
hey could someone help me with this error

somber nacelle
#

you've already been told how to solve it

simple egret
#

No, you don't

swift falcon
simple egret
#

Don't post in multiple channels, go learn C#

humble void
ashen yoke
#

i mean you sample all layers and select max

#

look into libnoise it should be a solved problem already

somber nacelle
ashen yoke
#

look through modules

#

libnoise is basically nodes, chain them, sample the chain

#

its much more convenient to work with than with raw functions, you can use or write a node editor and observe the changes in real time

#

which means you accelerate iterations

#

so even if you wont use it as is, use it as a playground to create desired results

pure cliff
gray mural
pure cliff
gray mural
#

also that was a small prototype snippet

pure cliff
#

are the Types all Types of various Enums?

gray mural
gray mural
#

every enum has its own type, so yes

pure cliff
#

I see...

why are you inflicting such a thing on yourself @_@;

gray mural
#

what do you mean?

pure cliff
#

usually holding a Type in a variable like this is a code smell unless you are doing something very fancy like making your own custom dependency injection engine

gray mural
#

there is no way to do it in another way with enums

pure cliff
#

and holding an array of Types is really far down that path

gray mural
#

you cannot just do enum[] allEnums

pure cliff
#

what are you trying to accomplish though

gray mural
#

I am making a DropdownEnum script for my game

#

so that options of dropdown that script is attached to are the same as specific enum's items

#

this is the only way to do it, so

pure cliff
#

...huh?

#

when you say "for my game" do you mean in game, or a custom inspector in the editor?

gray mural
#

so dropdown's options will be changed in OnValidate

#

I am just too lazy to write all options manually

pure cliff
#

this still hasnt gotten to the "but why" part

gray mural
#

also it doesn't seem to be correct

pure cliff
#

like super high level concept: Whats the end goal?

gray mural
ashen yoke
pure cliff
#

what problem are you trying to solve with all of this

gray mural
ashen yoke
#

you can create a custom inspector

pure cliff
#

no I scrolled really really far up, I seriously do not understand your end goal

#

like what do you need this dropdown for

#

lets say the dropdown is working.... then what

gray mural
pure cliff
#

whats the FINAL goal, whats the actual thing you are trying to achieve in the end

pure cliff
#

an inspector dropdown?

gray mural
gray mural
pure cliff
#

like keep going down the train track

gray mural
#

TMP_Dropdown

pure cliff
#

whats the goal

gray mural
pure cliff
#

Okay so, in game dropdown then?

gray mural
#

yes

simple egret
#

Settings menu maybe? Like quality presets, display settings (fullscreen, borderless)?

pure cliff
#

and you want to "bind" that dropdown to a specific enum, so its an enum value selector?

gray mural
simple egret
#

I'm trying to guess what the end goal is here

#

The Y of your XY problem

gray mural
#

I have said it so...

simple egret
#

No, you're too generic

gray mural
#

I think I have explained it well

#

also I want to learn how to do it

simple egret
#

We're missing the context

pure cliff
pure cliff
#

Like you have the FooEnum and you wanna bind "this in game dropdown has all the options for the FooEnum" yeah?

pure cliff
# gray mural yes

aight, is it runtime mutable? Like do you need to dynamically change "This specific dropdown now is actually the BarEnum values"?

Or will it be set at edit time (what enum a specific dropdown maps to), and then never change?

gray mural
#

edit time

pure cliff
#

basically: Do you need your options for a specific dropdown to be able to change dynamically in the middle of the game

gray mural
#

it will be changed at edit time

pure cliff
#

Aight, I wouldnt use enums at all for this then

gray mural
#

I will probably use most enums in settings

pure cliff
#

Enums arent the right use case here, what you have done is you have tried to re-create the Localization stuff unity has

gray mural
pure cliff
#

Cuz for actual strings displayed to the user, IE dropdowns, you should start with normal strings (not enums), and then later you can change from a normal string to a localized string

gray mural
pure cliff
#

yeah you have effectively re-invented the localization system

gray mural
#

isn't it how it's usually done?

pure cliff
#

nah

gray mural
#

how would you do this?

pure cliff
#

now we may still be able to enums and then your solution isnt terrible but

#

I have to sanity check if the localization system works for const accessible stuff in attributes

sage latch
#

What about making another class that sets the values?

gray mural
#

what do you mean by localization?

sage latch
#

I'll bring up some code

gray mural
sage latch
#

yes

gray mural
#

well, this sentence isn't so clear to me without any code or further explanations

sage latch
#

I'll get some code in here

simple egret
#

Localization: displaying different things depending on the user's locale settings (language, formats). Translation, simply said, but evolved to other stuff than strings

gray mural
#

or you can just explain?

gray mural
#

haven't ever worked with this stuff

#

but it may have troubles with enums I guess?

sage latch
#
public class EnumDropdown<T> : MonoBehaviour where T : Enum {
  TMP_Dropdown _dropdown;

  void Awake() {
    _drodown = GetComponent<TMP_Dropdown>();
    _dropdown.options = Enum.GetValues<T>().Select(value => new TMP_Dropdown.OptionData(value.ToString()));
  }
}
pure cliff
#

Localization effectively is the process of mapping KeyValuePairs of "Value" to "SomeString"

sage latch
gray mural
pure cliff
#

Im trying to look up how you can GetDisplayName of enums in Unity

gray mural
#

you can translate everything in GetString, so no problem

pure cliff
sage latch
#

Well you have to create child classes

pure cliff
#

MVC has an [Display(...) attribute you can put on enums to specify their human readable name

sage latch
#

because unity doesnt support generic monobehaviours out of the box

pure cliff
#

I know @hard viper found a lib for serializing Type, which is fine here if it can be narrowed down to specifically enums

gray mural
sage latch
#

I can show

gray mural
pure cliff
sage latch
#

I was just in a lol game

pure cliff
#

I do think a Type selector is prolly the right call here

#

but I think the "convert enum to string" logic can be simplified via an Attribute

#

unity already has a way to "nicefy" enum names sort of

gray mural
#

anyway I have almost done it already

sage latch
#

This class should work

public class EnumDropdown<T> : MonoBehaviour where T : Enum {
    TMP_Dropdown _dropdown;

    void Awake() {
        // Get the dropdown
        _dropdown = GetComponent<TMP_Dropdown>();
        // Get the values of the enum and construct a new OptionData from each
        _dropdown.options = Enum.GetValues(typeof(T)).Cast<T>()
            .Select(value => new TMP_Dropdown.OptionData(value.ToString())).ToList();
    }

    // _dropdown.value returns the currently selected index
    public T Value => (T)Enum.Parse(typeof(T), _dropdown.options[_dropdown.value].text);
}

And then create children with the specific enum type

public class LevelDiffDropdown : EnumDropdown<LevelDiff> { }
gray mural
#

I just have to find a way to get not enums from the full Assembly, but from #Scripts folder

hard mountain
sage latch
#

wdym, generic classes? @gray mural

gray mural
soft shard
sage latch
#

alternatively you can get the GenericUnityObjects package

gray mural
gray mural
hard mountain
#

You make a component that works for all enums. The UI controller class will pass the enum type to the component and then the component can read the enum values from that

gray mural
#

amonst Type[] allEnums

hard mountain
#

It's a lot less boilerplate

sage latch
#

i guess its a tradeoff

hard mountain
#

Yeah

gray mural
hard mountain
#

Hey if I'm working with unity i have to accept that sometimes i have to deal with tradeoffs like that

sage latch
#

It's a completely separate class

hard mountain
#

Also i dont remember where E : Enum being a thing, am i misremembering

sage latch
#

It constrains the type to be a child of Enum

pure cliff
sage latch
#

and thus only accepts enum values

hard mountain
#

I always thought you couldn't do it, huh

pure cliff
sage latch
sage latch
hard mountain
#

Oh wait that's kinda huge

pure cliff
#

ah yeah thats the shit

#

@gray mural that, that right there, thats the answer

pure cliff
sage latch
#

yeah

pure cliff
pure cliff
sage latch
#

I wouldn't call it life alterning

hard mountain
#

God i wish i found this earlier lol

sage latch
#

its more of a QoL

pure cliff
#

I would lol

hard mountain
#

It'd have saved a bunch of time for me

gray mural
pure cliff
#

when you need to be able to specify a type constraint of a monobehavior

sage latch
#

(unrelated to apples question) This is how it looks btw, it only shows the valid types in this nice dropdown

pure cliff
#

oh wait, okay so it still just creates the non generic class wrappers, it just automates creating them

sage latch
#

yes

pure cliff
#

Well... thats still pretty good I guess

#

it should be way better in terms of performance at least

sage latch
#

what would even be better?

hard mountain
#

Funky code generation

pure cliff
#

but this does seem like as close as you can get and its pretty close

sage latch
#

yeah ig

#

but without some insane reflection shenanigans i dont see it happening without code gen

hard mountain
#

My only wish is for interfaces to be assignable in editor

sage latch
#

That is the dream, yes

#

But not going to happen

hard mountain
#

Yeah it doesn't seem possible lol

pure cliff
#

oh like, that you drag and drop an interface ref

hard mountain
#

Yes

pure cliff
#

yeah itd be nice if there was an IMonoBehavior

hard mountain
#

Technically IComponent

sage latch
#

when would you ever want that though

hard mountain
#

I only remember that i needed it a few times, forgot the details

sage latch
#

MonoBehaviour has like 20 public members

pure cliff
sage latch
#

you would need to reimplement it every time

light rock
#

default interface implementations

sage latch
#

true

#

i always forget those exist

hard mountain
#

Wait that's c#?

pure cliff
sage latch
#

but why not an abstract class at that point

pure cliff
sage latch
#

if you want multiple inheritance

pure cliff
#

its like trying to progress towards C++ multip- YES exactly

light rock
#

multiple inheritance

pure cliff
#

which is not considered a great thing to have

light rock
#

well sometimes its useful

pure cliff
#

I dont remotely understand the appeal of default interface imps, it seems to violate everything C# stands for @_@;

hard mountain
#

Is default interface implementation even available in unity c#

somber nacelle
#

yes

hard mountain
#

I'm still on 2019.4 so i might not have it anyway though

somber nacelle
#

ah yeah probably not, it's a c# 8 feature

pure cliff
#

both my old and new job just straight up forbid using those til anyone could come up with an actual use case for the things, no one ever did

sage latch
#
public interface IResource {
    string Name { get; }
    Namespace Namespace { get; }
    string Location { get; }
    object Data { get; }
}

public interface IResource<out T> : IResource {
    new T Data { get; }
    object IResource.Data => Data!;
}
```This is the only use case I've met so far
#

(not unity)

hard mountain
#

I'd REALLY like to use it for my use case

sage latch
#

IEnumerator also has this stuff

light rock
pure cliff
light rock
#

old classes that implement it

hard mountain
#

Wait can't you just make an extension class and extend the interface

pure cliff
#

yeah that sounds like a bad idea

hard mountain
#

Why is this needed

lean sail
#

I use it in my save system to just specify the file name as => GetType().Name.
Each save file is by default saved under the class name and I dont need to specify the key in every single class

pure cliff
hard mountain
#

Huh

sage latch
#

Like I showed in my example?

pure cliff
sage latch
#

yes

gray mural
#

nice

sage latch
pure cliff
sage latch
#

orthogonal?

pure cliff
#

yes. You can achieve that result still without the weird default imp

#

you just re-invented the abstract class

sage latch
#

You can't inherit from multiple classes though

somber nacelle
#

interfaces shouldn't be a substitute for inheritance either though

pure cliff
#
public interface IResource 
{
    string Name { get; }
    Namespace Namespace { get; }
    string Location { get; }
    object Data { get; }
}

public interface IResource<out T> : IResource 
{
    new T Data { get; }
}

public abstract class Resource<out T> : IResource<out T>
{
   object IResource.Data => Data!;
   ...
}
pure cliff
sage latch
#

I agree

pure cliff
#

any greybeard C++ dev can prolly write an entire essay on why C#'s single inheritance system is something to celebrate, not try to circumvent

sage latch
#

but its implementations that are the problem, not the outfacing interface

soft shard
sage latch
#

It's to suppress the null warning

hard mountain
#

Null safety stuff

soft shard
#

Oh

sage latch
pure cliff
sage latch
pure cliff
sage latch
#

"composition over inheritance" yeah that's what im trying to say here

pure cliff
#

default interface imps are not composition

#

its weird pseudo inheritance and worse yet, multiple inheritance

#

its as far away from composition land as you can get

sage latch
#

Yeah, you should switch out abstract classes for interfaces

#

but that's not what my use case is about

pure cliff
#

well no, its not a principle of "switching out"

gray mural
pure cliff
#

composition is about "owns a", not of "is a"

gray mural
pure cliff
#

Static Extension Methods, and stuff like Decorator/Strategy pattern, are examples of Composition

hard mountain
#

I mean i feel like the default interface implementation is just syntatic sugar for doing the same thing with static extension

sage latch
pure cliff
#

extension methods "glass box" the logic

hard mountain
#

Can you elaborate more on this?

sage latch
#

I don't see how object IResource.Data => Data! hides anything from the children

pure cliff
#

if you add a default implementation method, the class implementing the interface now is altared

spiral ibex
#

Weird question, is there a way to prevent a component being added to a prefab/scene in the Editor?

sage latch
#

but I do get your point about default implementations circumventing the single inheritance

hard mountain
#

Unless im misunderstanding

spiral ibex
#

I think I misexplained it. I want this to not be possible. I think I can do this by deliberately naming the .cs file something else.

hard mountain
pure cliff
hard mountain
#

If anything it's more hidden with static extension since the logic is somewhere else entirely

pure cliff
#

effectively speaking, adding a default implementation to an interface can potentially break unit tests you have for the implementing class, as its behavior is now altered

hard mountain
#

There's no private / public when it comes to an interface iterface though, so what does outside perspective mean?

pure cliff
#

static extension methods, on the other hand, wont do this

hard mountain
#

Ah okay

#

I see your point now

spiral ibex
# gray mural yes

My renaming the file it exists in to no longer match the class name?

gray mural
#
[ExecuteAlways]
public class Smth : MonoBehaviour
{
    private void OnEnable()
    {
        if (GetComponent<Rigidbody>()) // if any condition
        {
            Debug.LogWarning("blabla");
            Destroy(this);
        }
    }
}
sage latch
pure cliff
#

basically default imps can result in:

"what the heck, our FooUnitTests are all breaking now, but git blame is saying FooUnity.cs hasnt been changed in several months, and we mock all our interfaces for injection of dependencies so... how the hell are the unit tests breaking now?"

hard mountain
#

That makes a lot of sense thank you

late lion
gray mural
#

if they add via inspector, it will work

#

they will have to invent their own condition

spiral ibex
gray mural
#

also e.g. you cannot add BoxCollider if gameObject has Rigidbody2D

#

they won't be able to create an error window like unity does though

pure cliff
# hard mountain That makes a lot of sense thank you

this is also a big reason why I never use inheritance for my services. it removes the possibility of code "somewhere else" changing and breaking my unit tests that have been glass box'd.

Inheritence: Foo inherits from Bar. FooUnitTests started breaking, despite Foo.cs never being altared... reason: Bar.cs got altared.

Composition: Foo depends on an IBar, but for the unit test we use a MockBar (usually via Moq) that we inject in, that way the only code that gets tested in FooUnitTests is purely the code inside of Foo.cs

However... if Foo : IFoo and now you throw default imps into the mix... that all goes right out the window D:

gray mural
sage latch
hard mountain
#

Yes i very much know how great interfaces are, i just didn't know the details about static extension like you explained earlier

pure cliff
gray mural
pure cliff
#

if you pick a new one itll prompt you to save the .cs file somewhere

sage latch
#

It doesn't even prompt you

gray mural
#

I wonder how they have done it just with c#

sage latch
#

It's open source, you can look in there

gray mural
#

I am too bad in generics to understand it

hard mountain
#

Well we know that it's code generation

pure cliff
sage latch
hard mountain
#

I.. did that just now lol

pure cliff
hard mountain
#

Made it because i had too many settings in my app

sage latch
#

but you could a prototype with just that

#

and saving to a random folder

sage latch
hard mountain
#

I have localization for my project

sage latch
#

Oh

#

I was so confused

hard mountain
#

I18n key just specify where to look for the translated text for each option

#

I18n is for internationalization (dumbest shorthand ever)

spiral ibex
#

Ngl that piece of code looks very weird to me

sage latch
#

C# before generics

gray mural
hard mountain
#

This is before i knew about genericunityobject lol

pure cliff
hard mountain
#

Yes

pure cliff
#

oh my god I have seen that so many times and I never realized thats what that was

lean sail
pure cliff
#

I always thought the I was an l

lean sail
#

thatd be l10n!

pure cliff
#

this is up there with k8s

spiral ibex
#

kates?

pure cliff
spiral ibex
#

who tf..

lean sail
#

l10n = localization

#

definitely some of the worst naming conventions ever

pure cliff
#

I hate the "stick a number in the middle of it" approach

hard mountain
#

I find myself guilty for using it

spiral ibex
#

I don't think I ever thought "you know what, my variables should have digits in them"

lean sail
#

i hate it but id hate typing a 20 character word at the same time

#

aint no way im spelling i18n without a typo

hidden flicker
#

How do I convert a Transform[] to a List<Transform>

spiral ibex
#

.ToList()

hard mountain
#

.ToList()

pure cliff
#

.ToListen()

hard mountain
#

But dont to it very often because memory

pure cliff
hidden flicker
#

"Transform[] does not contain a definiton for ToList"

sage latch
hard mountain
#

You have to add using System.Linq;

hidden flicker
hidden flicker
sage latch
#

No, that would be new List<Transform[]>()

lean sail
hard mountain
#

No that'd be new List<Transform[]>

gray mural
#

but why does it give me a warning now?

public class DropdownEnum<T> : MonoBehaviour where T : Enum
sage latch
#

Is the file named DropdownEnum?

urban wigeon
#

Pls guys help me

gray mural
leaden ice
urban wigeon
#

I exported my first charcter from blender as test, ma boy is clipping through the floor 💀

sage latch
hard mountain
gray mural
shrewd vessel
#

would this be the place to ask about TMPro questions? or should i go up to the beginner?

gray mural
#

oh, sorry, it's DropdownEnum.cs already

#

my bad

leaden ice
pure cliff
leaden ice
#

I see

pure cliff
#

Im definitely gonna add it to my toolbox, it seems super handy

hard mountain
#

Yes

pure cliff
sage latch
hard mountain
#

That's what kesomannen recommended

gray mural
pure cliff
sage latch
hard mountain
#

Oh no

sage latch
hard mountain
#

Okay I couldn't have used it anyway lol

sage latch
#

the top one looks correct except for the warning

hidden flicker
#

How do you remove a bone from a skinned mesh renderer

gray mural
shrewd vessel
sage latch
gray mural
sage latch
#

The warning might be a bug in the package

sage latch
hard mountain
gray mural
#

I see, well

hard mountain
#

That works i think

sage latch
gray mural
#

Thank you all for your help guys 😄 I appreciate taht

gray mural
sage latch
#

otherwise you can make your own class:

public class LevelDiffDropdown : EnumDropdown<LevelDiff> { }
#

do the job yourself

hard mountain
#

Or go the cursed route like that SettingsEnum.cs i sent

shrewd vessel
hidden flicker
hard mountain
#

It's probably the comparetag part then

#

I have never used tags in unity so I can't help you

pure cliff
#

specifically Staylow.enabled = true/false

hard mountain
#

Is it better to toggle the component or to toggle the activeness of the gameobject

sage latch
#

Depends

pure cliff
#

tbh I would actually expect its better to modify the culling mask of the camera :x

sage latch
#

umm

#

ok

pure cliff
#

thats how I go about it, get as low level as possible to minimize called logic

pure cliff
#

(can also just modify the display layer of the thing in question)

lean sail
pure cliff
#

stuff like sprites and canvas and whatnot

shrewd vessel
sage latch
#

But if the canvas is overlay mode then it doesnt work right?

pure cliff
#

still works, your camera has a bitmask for what it can "see" vs not

hard mountain
#

Why are you comparing tags though, what's the idea

lean sail
#

ah i couldnt find the context scrolling up

pure cliff
shrewd vessel
hard mountain
#

Yes but the way i see it you don't need the tags bit at all

#

Maybe?

sage latch
lean sail
shrewd vessel
pure cliff
hard mountain
#

Good to know

sage latch
#

But if you have children that could be weird

hard mountain
#

That has never been a performance issue for me but that's cool

sage latch
#

really depends on what you want

lean sail
#

from my experience though, its never really been a choice vs component or whole object, because of the different use cases

pure cliff
#

yeah like if its a button you prolly wanna disable the whole object, cuz the text of the button is a child

#

though I think the canvas button has a method to handle this?

steady moat
sage latch
hard mountain
sage latch
#

it does

hard mountain
#

Huh

hidden flicker
#

Can anyone help with removing a bone from a skinned mesh renderer :(

sage latch
hard mountain
#

I don't have any experience with these so can't help you

steady moat
lean sail
hard mountain
#

Ah right i forgot

#

Yeah canvas without camera will just render in overlay mode okay

lean sail
#

i think the "No cameras rendering" is the exception, or you can toggle if its shown i forget the specifics

shrewd vessel
#

Got it working, thanks guys! mixture of the Tags and then using TMP_text. heres the end result

leaden ice
#

it's going to happen regardless of the tag

hard mountain
#

Just warning you that the if statement is only guarding the debug.log

leaden ice
#

because of where you put the log

shrewd vessel
leaden ice
#

idk what "ascent" is

#

but your if statement is structured incorrectly

#

that's all we're saying

#

you need to swap the { and the Debug.Log lines

hard mountain
#

You probably want Staylow to activate only when the tag match from the looks of it

#

And that's not the case right now

shrewd vessel
hidden flicker
#

Still can't figure out bone removal :(

hard mountain
#

I really don't know how to help you

#

The only thing i can say is best of luck looking for a solution

hidden flicker
#

Yeah I'm asking people here who might know more, not specifically you

#

Thank you though

hard mountain
#

Working with unity can be frustrating like that sometimes

#

Last time i went insane because unity's inputfield implementation was so bad I had to extend it myself and modify the behaviour (i even used reflection to modify a private variable)

steep herald
#

is the [defaultexecutionorder] attribute reliable on all platforms?

glossy ledge
#

APPLE SIGN IN ICW PLAYFAB
Today I finished an update for the Android version of my game.
And tomorrow I will go back to the Apple IOS version.

Now the behavior, shop stuff etc works fine, but last time I tried, I really got stuck with the mandatory Apple Sign in and the fact that you have to push everything through XCode does not make it any easier ...

So I was wondering if anyone here had any experience with this specific issue and if they could give some pointers or links to resources (preferably a video where someone shows how it works) .

Then hopefully , if (and probably when) I get stuck with this (BLEEP) again, I have some straws to pull on 🙂

As always thanks in advance!!!

shadow hedge
#

if i wanted to make a AR and VR game. would it be better to work on the same project but in different scenes, or should i just make individual projects for both. Also they would both work the same. same scripts assets, etc

shadow hedge
#

alright thanks

hard viper
#

it serializes the identity of a class into an object of type TypeReference, and also lets you narrow the scope. Such as only allowing types that derive from a given baseclass, or implement a certain interface.

#

no bullshit typing strings, either. All type names get validated, so no spelling errors.

#

it uses reflection, obvs

knotty sun
#

Serializing type is easy. Type.AssemblyQualifiedName is a string, that is all you need

hard viper
#
[field: SerializeField] public ClassTypeReference tileMono { get; private set; }```
Cool. So you can do that in even less effort?
knotty sun
#

I see no Type there

hard viper
#

tileMono is an object with a Type field

#

tileMono.Type is the type that it corresponds to

#

and it comes with a property drawer

knotty sun
#

so
ClassTypeReference<TileMonobehaviour> tileMono
would not do the same?

hard viper
#

TypeReference is not a generic

knotty sun
#

why not?

hard viper
#

it doesn't need to be

#

it just has a Type field. That's all you need

knotty sun
#

if it's using reflection it should be

#

this is a typical c++ hack for something that c# solved long ago

hard viper
#

actually I don't see System.Reflection. I thought Type was in the reflection namespace

#

so it doesn't use reflection

late lion
#

Eh, it's the entry point to Reflection. Pretty much everything in it is Reflection.

hard viper
#

so ClassTypeReference does NOT use System.Reflection. The property drawer DOES

#

I assume this is so it can be fast as shit during runtime

late lion
#

It's still serializing a string, and needs to use Reflection to resolve the type from the string.

hard viper
#

that's what I assume is going on

#

that it uses reflection only in editor

#

anyway. it works great. super simple. strong recommend

zealous karma
#

Hi lovely ppl. I wanna ask you for help. Im making a little raft where the player can move freely and control the boat when interacting with the steer by pressing e. Does anyone know any type of video tutorial for a almost complete beginner on how to enter/exit a vehicle and how to steer the boat by rotation? Pls DM or poke me, I would be really gratful UnityChanHelp

eager wagon
#

hi, i have a question, why if i decelerate a 5 elements array (public bool[] cd = new bool[4];) unity says no and make it 4, crashing the game when i try to change it via teh editor

rigid island
lean sail
#

im guessing that is supposed to mean declare

dusk apex
#

That's a four element array 0-3

lean sail
dusk apex
#

4 is the length (delimiter)

eager wagon
#

damm i see i have a problem with teh names

rigid island
#

the important take away is taht arrays start from index 0

lean sail
eager wagon
#

but unity editor only displays 4

rigid island
lean sail
#

yes because you wrote new bool[4], which is the size

rigid island
#

as size

eager wagon
#

public bool[] cd = new bool[4];

rigid island
lean sail
#

we understand and we are telling you whats wrong!

dusk apex
eager wagon
dusk apex
eager wagon
#

should be 5

#

and its 4

rigid island
eager wagon
#

thats teh problem

lean sail
#

i feel like this is a troll

dusk apex
eager wagon
#

i write 5 and it doesnt change

rigid island
eager wagon
#

i can write 5000 and still 4

dusk apex
#

You'll have to reset the component or modify it from the inspector

eager wagon
rigid island
#

when you serilized it in the inspector

eager wagon
dusk apex
#

When you create the instance (add the component), the default values are used.

rigid island
dusk apex
#

Thereafter, they're independent of the default values assigned during declaration

eager wagon
eager wagon
#

wana call??

dusk apex
rigid island
#

or use windows screen recorder or OBS

eager wagon
rigid island
#

which version of unity btw

eager wagon
#

2021.3.25f1

dusk apex
eager wagon
#

idk tried now with other array and isnt happening

dusk apex
eager wagon
#

i didnt touched nothing, and now its solved, should this be a bug report?

marble swift
#

what could be the reason that like 1/10 times my code work and the other times not. im not clicking anything and right after starting im getting argumentNullException Value cannot be null

dusk apex
marble swift
eager wagon
#

probably a gameobject whit nothing assigned

dusk apex
eager wagon
#

dont miss the semicolon

marble swift
marble swift
#

but why would it work then flawlessly sometimes

eager wagon
#

if teh editor know there is a missing semicolon, why dont put the semicolon

dusk apex
river sentinel
#

So, why is my Player-layer object apparently treating another player-layer object as a collision-layer object? When player-layers, according to my physics2D settings, players can only interact with collision, not themselves.

dusk apex
#

No, there isn't a known issue that's specific to your case that you've not told us about yet that's happened before.

rancid sable
marble swift
river sentinel
marble swift
dusk apex
river sentinel
#

some children are on default layer but that shouldn't collide with anything given my settings

marble swift
rancid sable
#

(assuming the children with colliders are on the default layer)

dusk apex
pure cliff
#

Thats usually a race condition, Id bet on it

#

Whats the line of code that is throwing the null exception?

dusk apex
#

NRE means something was null

marble swift
river sentinel
#

they do not, only the player and collision objects have colliders. And I have castfilters for checking walls and ground that filter out the player.

pure cliff
dusk apex
rancid sable
rancid sable
river sentinel
# rancid sable then I'm out of ideas without source code/video or something

RELEVANT: Three layers are made for this project atm. Player, Collision, and Floor Collision. Player objects use the Player layer, collision meant to be stood on goes on the Floor Collision layer, and walls are tied to the Collision layer. groundFilter only focuses on Floor Collision and wallFilter only focuses on Collision.

public ContactFilter2D groundFilter;
public ContactFilter2D wallFilter;
    private float groundDistance = 0.05f;
    [SerializeField] private float wallDistance = 0.2f;
    private float ceilingDistance = 0.05f;
    [SerializeField] private float wallBuffer;

    CapsuleCollider2D touchingCol;


    RaycastHit2D[] groundHits = new RaycastHit2D[5];
    RaycastHit2D[] wallHits = new RaycastHit2D[5];
    RaycastHit2D[] ceilingHits = new RaycastHit2D[5];

CapsuleCollider2D touchingCol;

private void FixedUpdate()
    {
        IsGrounded = touchingCol.Cast(Vector2.down, groundFilter, groundHits, groundDistance) > 0;
        IsOnWall = touchingCol.Cast(wallCheckDirection, wallFilter, wallHits, wallDistance) > 0;
        IsOnCeiling = touchingCol.Cast(Vector2.up, groundFilter, ceilingHits, ceilingDistance) > 0;
    }``` (I'd include an error message but it's semantic)
pure cliff
#

this is why I heavily avoid using Awake/Start on monobehaviors, if I have to sit and start specifying what order stuff happens in, that way lies spaghetti town

dusk apex
#

Showing the error is very important

#

Show us the console error

rancid sable
#

could someone else help Zwataketa out?

marble swift
dusk apex
pure cliff
dusk apex
#

Which can very likely return null

pure cliff