#archived-code-advanced

1 messages · Page 145 of 1

final kindle
#

Guess that means odd functions about the place unless I want to repeat code everywhere, but oh well I guess that's a small price to pay.

kindred tusk
#

One consideration here is that your code path in the #else won't be run until you build, so it can lead to undetected compile errors. Sometimes it's kind of cleaner to use the boolean check instead (they're not that expensive). The preprocessor guards are necessary if you want to conditionally exclude a library completely, for example UnityEditor

final kindle
leaden jungle
#

Hey I have an advanced programming question, not unity specific, but I haven't been able to figure it out. I've been using a pattern that I want to identify. Not sure if it is some sort of state machine or something else. I 1st encountered this pattern in this GDC video: https://www.youtube.com/watch?v=tAbBID3N64A
I'm talking about the bark system. In the video they call it a self branching dialog tree, but say it could be extended to do much more. I have used this pattern to make a dialog system and a character controller. Then I wanted a name for it so did a lot of research and found Fuzzy State Machine which seems a good fit because you can have more than one active state at a time, however you can set it up as finite states and also add and remove states dynamically. The other system it sounds a lot like is a utility function, but rather than analyze the possibilities as floats and calculate the best choice, this system compares everything with bools and returns the 1st match rather than the best match.

GDC

In this classic GDC 2012 session, programmer Elan Ruskin shows a simple, uniform mechanism made for the Left 4 Dead series for tracking thousands of facts and possibilities, allowing intelligent characters to remember history, cascade from special to general cases, and select the optimal dialog, script, behavior, or animation for every situation...

▶ Play video
native hinge
#

Hey, first time using the IEnumerable.Where() method, did I do it right?

SaveFile[] matchingFiles = UnityEngine.Object.FindObjectsOfType<SaveFile>().Where(s => s.slot == slot).ToArray();
if (matchingFiles.Length > 1)
{
    Debug.Log($"Length of files with slot {slot} is greater than 1.");
    return;
}
#

Oh btw slot is a parameter that the function takes in public static void Save(int slot)

rocky zephyr
native hinge
#

Right now I'm only saving a single string; the player's name

rocky zephyr
native hinge
#

To a text file

#

File.WriteAllLines(filePath, new string[] { name });

rocky zephyr
#

Ah the asset you’re loading is a text file. I guess you could load a text file this way but I would have expected file operations to be used. Good luck!

native hinge
#

File operations?

#

I've never made a save system before

#

Not a real one anyway

undone coral
#

then use the unityengine mocks from anywhere

compact ether
#
    {
        if (lookAt != null)
        {
            Vector3 dir = new Vector3(0, 0, -distance);
            Quaternion rotation = Quaternion.Euler(currentY, currentX, 0);
            transform.position = lookAt.position + rotation * dir;
            transform.LookAt(lookAt);
        }
    }```
So I have this function that I am using on my 3rd person camera script. It is actually working fantastic for my needs, but I want to implement 1 quality of life improvement. Can someone please help my game start with camera facing behind my damn character? It just finds my object, and seemingly faces the same direction, no matter what way I move my character. Any suggestions or help would be totally appreciated
stable spear
#

@compact ether Is lookAt starting out null or something?

#

where are currentX and currentY coming from?

#

those determine the direction of the camera

compact ether
#

So I just came up with a solution that works for me. Basically I add an offset to the currentX input from my controller. It's not perfect, but it works haha.

rocky zephyr
surreal vessel
#

for whatever reason

#

if i store a single object its fine but when i turn that into a list suddenly it just returns null everytime

#

and its really annoyinh

compact ingot
#

read the docs JsonUtility.ToJson

Note that while it is possible to pass primitive types to this method, the results may not be what you expect; instead of serializing them directly, the method will attempt to serialize their public instance fields, producing an empty object as a result. Similarly, passing an array to this method will not produce a JSON array containing each element, but an object containing the public fields of the array object itself (of which there are none). To serialize the actual content of an array or primitive type, it is necessary to wrap it in a class or struct.

surreal vessel
#

i suppose i should make classes for things such as an item list

#

since i use that in both my inventory and storage containers

fresh salmon
#

Yup, or switch to a more feature-extensive serializer like Newtonsoft.json, it handles top-level collections like any other type.

surreal vessel
#

since then when i want to access an inventory item

#

instead of inventory.contents[1] id have to do soemthing like inventory.contents.contents[1]

#

and that doesnt seem right

#

i dont have the brainpower to do this lol

fallen halo
#

what happens if i make the distance parameter of BoxCast in unity2d to 0

junior sorrel
#

Hello, I'm having mesh positioning issue and I can't figure what's causing it
Here the enemy(black square) is aiming towards player(red diamond) and you can see that I'm using this mesh as a field of view

I used CodeMonkey tutorial: https://www.youtube.com/watch?v=CSeUMTaNFYk

The origin position of the mesh has an offset and when I literally just copied the code of the tutorial I'd still have the same behavior.

I did google about it a bit but and found one solution that would make sense but it didn't help me
Link: https://answers.unity.com/questions/191774/meshvertices-position-not-correct.html

What could be the problem?

snow grotto
#

Have you checked if the enemy is not childed with an offset, probably not it but always have to check

junior sorrel
snow grotto
#

O oke, so the fov mesh is not a separate object, is the fov mesh renderer on the enemy gameobject?

junior sorrel
#

Yes, it's on the enemy gameobject

undone coral
#

what is your gameplay objective

#

that screenshot doesn't look like anything

snow grotto
#

If you have it on a separate gameobject does it still have the offset from the pivot?

undone coral
#

the codemonkey script is buggy

snow grotto
undone coral
#

maybe use an asset store asset

junior sorrel
undone coral
#

you gotta understand the script otherwise this is gonna be tough

snow grotto
#

^

junior sorrel
#

Yeah I do my guy

grand falcon
#

Hey I have animator overrides controllers created for each NPC. When the NPC gets spawned I am changing the animator runtime controller by :
anim.runtimeAnimatorController = Resources.Load<AnimatorOverrideController>("/ai_holder/_Animator");

Why doesn't the sprite change? Even though the override controller has the animations and sprites are attached to the animations.

Also the game is a multiplayer with Mirror.

junior sorrel
#

I do understand it and it doesn't make sense that's it's not behaving the way I want

undone coral
#

and covers what you want

humble onyx
undone coral
#

it is likely the path name has changed because you have "(Clone)" in the path. using Resources here is odd

junior sorrel
snow grotto
#

O are you making the mesh based on raycasts that return world positions?

grand falcon
junior sorrel
humble onyx
grand falcon
#

Oh sorry yeah it is also set

humble onyx
#

mmm interesting
does it work if you dont load it from the resources folder?

grand falcon
#

It works if i predefine it before spawning in runtime

#

haven't tried not loading it from resources

#

didn't occur to me that it might be a problem

humble onyx
#

im not sure how unity hadles that references to the sprites

#

that why im asking

undone coral
#

that's really unusual

#

what is Ai

#

it should say SpriteRenderer.Sprite

grand falcon
#

really daamn didn't know that

#

it says that cause I have a code that makes the animations from the sprite library that I have 😄

undone coral
#

i think there's a lot going on with your setup

#

that's a little dubious

grand falcon
#

Thanks I hope this helps 🙂 @undone coral @humble onyx Thank you too 🙂

#

I am learning as I go and I try to automate as much as possible 🙂

undone coral
#

okay

#

i think you should just set these up by hand for now

#

and see if it works normally

grand falcon
#

Not sure if I am doing things correctly but hey I got to learn 😄

#

if i set it up by hand it works fine

#

but there are loads of sprites and it just seem like a waste of time if you can make the computer do it for you 😛

runic tendon
#

Is there any way to run code for particular locales? I fired some events after comparing the current locale was equal to some locale assets. It works in editor but not in build. I think that might have been due to locales being addressables.
I tried saving and comparing the identifier strings but that did not work either.

undone coral
runic tendon
undone coral
undone coral
#

it sounds like you've tried the most obvious way to get this working

#

so i'm not sure

#

it should really be that obvious

#

as obvious at switching on the locale*

#

sounds like something else is busted

past pendant
#

would someone be able to provide me an example of some code that would allow the player models head to move up or down depending on where the mouse is?

cursive horizon
past pendant
#

well all i got is a FPS controller i've not started to try to do it

cursive horizon
past pendant
#

well i was just asking before i tried because i don't even know where to start for it but ill give it a go for now

cursive horizon
#

but that's why it's good for you to try first, because then you'll realize that you need to answer those questions (or at least can come here with something more specific)

past pendant
#

ok thanks ill come back later once i have tried

cursive horizon
past pendant
#

it seems that AvatarIKGoal dose not contain the head just the hands and feet

#

so when trying to set the position of the head its not going to work

#

I'm basically trying to move the head up and down to follow the mouse

#

its a 3d head

cursive horizon
#

is it first person? third person? a picture is worth 1000 wordss

past pendant
cursive horizon
#

you want the head to rotate

cursive horizon
past pendant
#

if that's what it is then yes, sorry I'm bad with words I'm mentally a 7 year old

cursive horizon
past pendant
#

how

#

so your saying having autism is weird

cursive horizon
#

nah, i just can tell from talking to you that you aren't 7 years old 🤷‍♂️

#

give yourself some credit, we're all just trying to figure stuff out here

#

but it's worth it to try to be specific so that people can help you more easily

past pendant
#

im trying my best im 17 and not been in school for 3 years

#

so with what you know about what I'm trying to do is there any possible way your able to help?

cursive horizon
past pendant
#

the video got removed for me

cursive horizon
past pendant
#

oof im blind thanks

cursive horizon
#

But yeah, I think that's the right track. You want to use some simple IK to point the head, with the cursor as the LookAt target and see how that goes

past pendant
#

well i don't get no error but just is not working

#

still don't work if its in its own script ```cs
using UnityEngine;

[RequireComponent(typeof(Animator))]

public class IKMouseLook : MonoBehaviour {

protected Animator m_Anim;
public Transform lookObj = null;
public float m_LookWeight;
public float m_BodyWeight;
public float m_HeadWeight;
public float m_EyesWeight;
public float m_ClampWeight;

void Start() {
    m_Anim = GetComponent<Animator>();
}

void OnAnimatorIK() {
    m_Anim.SetLookAtWeight(m_LookWeight, m_BodyWeight, m_HeadWeight, m_EyesWeight, m_ClampWeight);
    m_Anim.SetLookAtPosition(lookObj.transform.position);
}

}

#

i set the lookObj to a cube and nothing

past pendant
#

ok so i got it to work but its using Vector3 but i need it to be moving to where the player is looking

stable spear
#

not 100% sure that's important, but it should be added to check

#

In general functions with different parameter lists are considered different

#

add a Debug.Log() to the method to make sure it is being called

past pendant
#

so its going this but insted if the vector3 it need to look at where the player is looking ```cs
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class HeadRotatorBone : MonoBehaviour {

// Bone rotate vector
public Vector3 rot = new Vector3(20, 30, 10);
Animator anim;

//  Bone stuff
//Transform head;
void Start () {
    // get attached Animator controller
    anim = GetComponent<Animator>();
    //head = anim.GetBoneTransform(HumanBodyBones.Head);
}

void OnAnimatorIK (int layerIndex) {
    print ("OnAnimatorIK - running");
    // Convert bone rotate vector to Quaternion and rotate head bone
    anim.SetBoneLocalRotation(HumanBodyBones.Head, Quaternion.Euler(rot));
}

}

stable spear
#

what determines where the player is looking?

past pendant
#

this i guess```cs
// Player and Camera rotation
if (canMove) {
rotationX += -Input.GetAxis("Mouse Y") * lookSpeed;
rotationX = Mathf.Clamp(rotationX, -lookXLimit, lookXLimit);
playerCamera.transform.localRotation = Quaternion.Euler(rotationX, 0, 0);
transform.rotation *= Quaternion.Euler(0, Input.GetAxis("Mouse X") * lookSpeed, 0);
}

stable spear
#

in that code, is transform the camera transform?

past pendant
#

yes

#

as far as im aware

stable spear
#

so you could just use transform.rotation in your call to SetBoneLocalRotation ? But this would be kind of weird, since if camera does a 360 spin, the head would also spin 360

#

if the animation is being rotated independently, you may need to divide outs its existing rotation

past pendant
#

ok so its just looking straight down

#

even with this ```cs
anim.SetBoneLocalRotation(HumanBodyBones.Head, transform.rotation);

tough tulip
#

take a reference point (camera presumably) add some offset to it. and then try to calculate the rotation needed for player to look at that point and apply the rotation

undone coral
past pendant
#

no just trying to make the head rotate up or down when the player looks up or down

past pendant
#

its 3d and its first person

undone coral
#

yeah

#

you definitely want to do this with animation rigging

#

In this video you will learn how the Animation Rigging package can improve animation in your project via better tools and more flexible workflows. Discover how to setup a character, and harness both runtime rigging and animation authoring in this practical demonstration aimed at riggers, animators, and cinematic designers.

Speaker:
Ciro Contini...

▶ Play video
#

the code you're writing is really far from working, this is already all in the animation rigging package

#

@past pendant is this helpful?

past pendant
#

no because its nothing to do with the rigging the rigging is all done

undone coral
#

you would move the transform

#

well, this is a rigging problem

#

i don't know what to tell you

#

you could have it working in 5-10 minutes with animation rigging

#

right now you're trying to solve for a bone rotation which isn't going to work

past pendant
#

i was told to use IK

undone coral
#

animation rigging be, place a transform somewhere along the direction the player is looking

#

well this is even simpler

#

because that time i linked you to

#

shows exactly what you want

#

in a brackey's tutorial, which means it couldn't be that hard

past pendant
#

but that is looking at a object not what i want i want it to just move up and down when the player moves the mouse up or down

undone coral
#

it's not looking at an object

#

it's using a transform as part of a solution to moving the head up and down

#

where's the object?

#

do you see an object in this tutorial video?

#

i don't know, 100% of your code is wrong

#

every single line

undone coral
#

so it's tough, you should probably use the animation rigging package

#

then everything will just work! 🙂

#

you're reinventing the animation rigging package right now, which is hard

#

you've made zero progress on that

#

you want to make the head move up and down? use animation rigging

#

you can place the transform you're looking at along the forward of the player camera in world space

#

that's it, the model will always look

#

i guess this is for making reflections look good?

past pendant
undone coral
# past pendant would you be able to provide a code example?
// a reference to the transform
// you've configured via animation
// rigging to be the target of
// the head
Transform headTarget;
void Update() {
 headTarget.transform.position = 
  playerCamera.transform.position +
  playerCamera.transform.forward * 10f;
}
#

that's it

#

does that make sense?

#

do you see how much simpler this effect gets with animation rigging

past pendant
#

ok i understand it kinda i don't get the animation part

undone coral
#
headTarget.transform.position =
 playerCamera.transform.TransformPoint(
  Vector3.forward * 10f);

also works, it's the same

undone coral
past pendant
#

what the Brackeys one?

past pendant
#

the head is just not moving

fallen halo
#

how do i create a highly modular COMBO system. without using mechanim

reef wren
# undone coral https://youtu.be/Htl7ysv10Qs?t=446

I used multi aim constraint just like how its shown in video. but im unable to move my target like brackeys does.
i hit play mode, my character looks at the target transform. but i cant move that transform at runtime (in playmode) at which the head is looking

past pendant
reef wren
past pendant
#

Yeah I can move it freely in the inspector but just not following the target

hot dock
#

Does anyone know how to write this, so that it is compatible with 2020.3?

public IEnumerable<T> GetNodes<T>() => nodes.OfType<T>();

Apparently OfType is not available.

#

I wrote it like this, but apparently does not work exactly the same...

public IEnumerable<T> GetNodes<T>() => (IEnumerable<T>)nodes.ToList().Where(x => x.GetType() == typeof(T));

hot dock
sly grove
#

Does UQueryState implement IEnumerable?

#

Also have you included using System.Linq; ?

hot dock
#

If it didn't it wouldnt work on 2021

sly grove
#

not necessarily

hot dock
#

this is my code, btw

sly grove
#

they may have added that interface to the type in 2021

reef wren
#

it happens in 2021.2.0f1 but it doesnt happen in 2020.3

sly grove
hot dock
#

That code does not run in 2020

#

That runs only in 2021

sly grove
#

"does not run" meaning what? Doesn't compile? Throws some kind of error?

hot dock
#

I guess it does not implement IEnumerable... no?

sly grove
#

That strongly implies that Your version of UQueryState does not implement IEnumerable

#

If you ctrl + click on UQueryState to look at the struct definition in VS it will show you

hot dock
#

I am using Rider

#

But let me try

#

I guess this means "no"

sly grove
#

yepo

hot dock
#

Well, good news

sly grove
#

it would have another , IEnumerable<something>

hot dock
#

All I need to do is this

sly grove
#

👍

hot dock
#

Thanks for your help, mate

#

By the way, what do you think about my "other" solution, with the Cast function?

sly grove
#

Idk anything about UIElements so I won't comment ¯_(ツ)_/¯

hot dock
#

hahaha

#

Well, thanks anyway 🙂

#

You saved me 🙂

white cliff
#

Anyone know some good tutorials for third person character controller with root motion?

hot dock
#

@sly grove You were right

#

That is in 2021

distant pendant
#

Figured I might ask this here because it more toward c# as opposed to unity and is something that was hard to solve in the other code areas. For the purpose of convinience, are you allowed to create a list or array of variables that can later be assigned values?

For example if I have a for loop with I as the iteration variable, and I have an array or list of variable names, can I go like
listOfVariables[i] = listOfValues[i]

shadow seal
#

All the channels are for C# in Unity, this one isn't more "Csharpy". You were asked to clarify what you wanted in #💻┃code-beginner so my advice is you go and provide some detail

distant pendant
#

My bad thanks

past pendant
vapid mauve
#

doesn't seem like coding is involved, so you may have more luck in #🏃┃animation ?

amber yoke
#

Maybe I have more success here. I am trying to have A List<Events> that contains different Lists like List<TeleportationEvent>, List<SubQuestEvent>. And then serialise it with JSON. My approach of having Events being a simple interface which TeleportationEvent and SubQuestEvent implement has not worked. Do you have a better approach?

somber tendon
#

I'm curious with this tips, where did you get it?

where the tips they says is that use unity animation events for things like visual or sound or other stuff. don't use them if your script is dependent on them.
I'm making a prototype with the same combo concept, based on animation event to determine when can the combo can be chained

fallen halo
#

the question on this site. What do you think is it a good a to do this:-
I am creating a combo attack system. But i am not using any timers to chain the attacks to create a combo. Rather i am using unity animation event. For example:
Attack 1 has 5 frame animation.
On the 2nd frame of the animation i put an event that turns a bool called "attackChainable" true.
On the last frame of the animation i put an event that turns "attackChainable" bool false.
If i press the attack button when attackChainable is true i can transition to the second attack and so on and on. basically doing a combo. there's more to it but that is the basic gist.
But i read online where the tips they says is that use unity animation events for things like visual or sound or other stuff. don't use them if your script is dependent on them.
So, should i stop doing combo system that is dependent of unity animation event?

snow grotto
#

@fallen halo if that works well I think that it's a good way of going about it, your avoiding dealing with multiple checks and timers. Make sure the game can't be blocked/soft locked in any way if the animation stops before the bool turns off again.

You could also run a enumerator that adds and later removes attack types like an enum in to a list of some sorts and everytime you call attack you can check what current attacks are on going and continue a combo, this will also allow you to do multiple types of combos

fallen halo
snow grotto
#

No, that's just what I came up with. I'll try quickly making it when I get home so you see what I mean

fallen halo
#

ok

final kindle
#

How is mouse wheel supposed to be handled? (Old input system). When I scroll, the delta returned is either 3 or -3. I've heard from a friend that's the systems scroll setting, so 3 lines, but I don't know if that's true or how I would get that as a value to scale by. I could of course normalise it, but unless this can't actually happen, that would mean any time it registers something like a delta of 6 or 9, it'll get normalised as if it wasn't scrolled more than just scrolling to a delta of 3. Any advice?

surreal plaza
#

Are merge conflicts inevitable?

#

I've heard that some teams keep track of who's using which files.

#

Is there an existing file lock tool for doing that?

sly grove
#

Some version control software has a concept of "checking out" a file which gives you exclusive rights to modify it

#

I think Plastic SCM has this? Which is what Unity is replacing Collaborate with

#

Subversion has it too IIRC

modest lintel
#

Perforce has support for locking scene and prefabs in Unity too

plucky laurel
#

git has locks now

plucky laurel
#

its just a thing you deal with, locking files that are not easily mergeable is common

cedar ledge
#

I'm having trouble with OnValidate(). I can't have it run unless all gameobjects are loaded in the scene, so I created this:

protected async override void OnValidate()
{
    base.OnValidate();
    await Extensions.WaitUntil(() => SceneDetector.SceneIsLoaded);
    SetPower(isPowered);
}

which successfully stops errors from happening when I open up the project INTO this scene where the script is. however, now I'm getting errors when I switch AWAY from the scene into a different one (where this script is not on any game object). how can/should I filter these validates? I'm already trying to detect if the scene is completely loaded using Opened and Open delegates in my SceneDetector class, but somehow that doesn't stop these errors.

#

PressurePlate is the gameobject with the script trying to validate, and it has a boxcollider2d

#

the error is definitely the base.OnValidate()

#

i think i might have just solved it by moving the waituntil above the base call, adding a timeout to the waituntil, and catching the timeoutexception (and then returning)

#

that seems to have done the trick

worthy sedge
#

I have a question.
Let's say I have a card game and I'm casting a card. I have a CastManager that is in charge of managing the effects but sometimes the CastManager needs to prompt a player for something (like for example picking a target to deal damage to).
Any easy way of making an I/O system that's ambiguous to different types of prompts? Like does Unity have an equivalent to Java's Scanner.Keyboard or C++'s CIn?

#

I implemented a pop-up button box for players to click, I just want to wire the game to wait for users to click one of the responses.

fresh salmon
#

Or an UI object that covers all the screen, so it blocks events from reaching whatever's in the background

leaden jungle
sly grove
plucky laurel
#

@worthy sedge input in unity is not event based

#

it can be wrapped into event surrogate (most libs do)

onyx hearth
#

So, I'm kind of stuck here. I'm trying to get the height of a wave based on an x position in Unity. I'm not using a shader graph for the waves so I don't quite know how to achieve this.

plucky laurel
#

i.e. Rewired allows you to subscribe to input actions, so you can be reactive

#

same for new unity input system

#

in case you want to block the thread until it happens - no

#

the input polling is .. async? i guess

onyx hearth
#

(also since hastebins no longer about, where would I put code so I don't dump 100 lines on you.)

plucky laurel
#

simulation time can be affected as @twilit hare said by Time.timeScale

#

setting it to zero and ensuring the game is using the deltaTime, will effectively suspend the simulation

onyx hearth
#

Mathf.Sin, that much I understand, but I really don't get what inputs I need.

plucky laurel
#

meanwhile the ui which should be using Time.unscaledDeltaTime will work in realtime

onyx hearth
plucky laurel
#

they both run on the same thread, and blocking it is not an option

worthy sedge
plucky laurel
#

but frames are time agnostic

#

time is an abstraction

#

its just a number handled by unity system that executes each frame

plucky laurel
#

whether the time is zero or not bears no effect on the game loop

sly grove
#

It simply changes what Time.time and Time.deltaTime are going to be giving you in future frames

#

The only actual effect it has on the game loop is to make FixedUpdate run more or less frequently (in terms of real time), since FixedUpdate is called based on scaled elapsed time.

plucky laurel
#

true

#

fixedUpdate is also decoupled from the framerate

#

together with time

worthy sedge
#

So in other words fiddling around with that may not be my best option here for me... I'm developing a card game which is a turn-based sort of game with a lot of UI game objects. For user input I was thinking of possibly using delegates but I wanted to see if there was a built-in thing that could make it to where I could stop a function from finishing until some form of input has been given.

#

I was hoping to save some time from hardcoding more functions 😅

plucky laurel
#

you can use async

#

there are several implementations of async for unity, the c# async, UniTask, coroutines, and MEC (coroutine library)

worthy sedge
#

Alright, I'll take a gander at those

plucky laurel
#

there is also UniRx which should be familiar if you worked with js reactive approaches

cedar ledge
cedar ledge
#

or await Extensions.WaitUntil(() => YOUR_CONDITION_HERE);

#

Extensions.cs:

public static async Task WaitUntil(Func<bool> condition, int frequency = 25, int timeout = -1)
{
    var waitTask = Task.Run(async () =>
    {
    while(!condition())
        {
            await Task.Delay(frequency);
        }
    });
    if(waitTask != await Task.WhenAny(waitTask, Task.Delay(timeout)))
    {
        throw new TimeoutException();
    }
}
worthy sedge
misty glade
#

I would also explore whether a callback with an Action would work for you. You make a gameobject/prefab panel and tell it to display itself with a callback to the handler.. bonus, if the user selects nothing (or cancels) then you can put the card back into their hand

#

So for example, I have something similar for a dialog box for a user to select a crew member for a given position. They click on the empty position, a dialog box pops up, and when the user selects a crew member, the dialog disappears and the callback is executed:

cedar ledge
#

awaiting input definitely seems more jank than an event/callback

sly grove
#

something's gotta invoke that callback

cedar ledge
#

the input gameobject or whatever

#

if its a textbox run the callback when Enter is pressed

sly grove
#

yea - new input system has event-based input built in though, so that might help

misty glade
#
        private SelectPersonPopup _selectPersonPopup = null;
        _selectPersonPopup.OpenSelectPersonDialog(OnSelectCrew1Callback, Crew1.Person);


        public void OpenSelectPersonDialog(Action<Person> callback, Person selectedPerson)
        {
            gameObject.SetActive(true);
            .. and some other stuff ...
        }

        public void OnOKClicked()
        {
            gameObject.SetActive(false);
            _callback?.Invoke(_selectedPerson);
        }
cedar ledge
#

nullable reference types 😍

fresh salmon
#

If they ever implement NRTs in Unity (they actually have to switch to .NET and quit Mono), I hope it helps build safer code, especially for beginners and their NullReferenceExceptions

#

But in the state it's currently in, it's far from perfect, I would advise against using it

misty glade
#

I can't imagine they will, that's such a major-impact breaking change because of their "special null", from what I understand

cedar ledge
#

and I'm currently using them

misty glade
#

On MonoBehaviours?

cedar ledge
#

yeah

fresh salmon
#

Oh, in the newest versions? With the #nullable enable and string? for example

cedar ledge
#
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

#nullable enable
public class PressurePlate : ColorDevice
{
    [SerializeField]
    private float offDelay = 1f;

    private HashSet<Collider2D>? touching;
    private SpriteRenderer? sr;
    private IEnumerator? powerOffTask = null;
...
#

yeah

misty glade
#

derp? I didn't think that was possible - I mean, I know you can force it to work by setting the language version or #nullable pragma but .. I thought it was guaranteed to break stuff

cedar ledge
#

you just have to set the language spec to 8

misty glade
#

hm.. lemme try to find the page I was reading the other day about it

cedar ledge
#

that's what i'm doing atm

misty glade
#

I wanted to use the elvis operator for accessing a deep node without doing null checks "down the path" and gave up

#

ie something like:

cedar ledge
#

you can expose the project properties, too

fresh salmon
#

Heh weird it allows it, since even the docs advise against using ?., ?? or ??= on anything that derives from UnityEngine.Object

misty glade
#

something = gameObject.transform.GetChild(0)?.GetComponent<T>()?.GetMember();
fresh salmon
#

^ That works without the NRTs enabled

cedar ledge
#

so dont do those

cedar ledge
#

'?.' on a type deriving from 'UnityEngine.Object' bypasses the lifetime check on the underlying Unity engine object

#

but it still helps point out where things can be null with the green underlines

misty glade
#

yeah, I mean, it seems like .. dangerzone to use nullable referencce types when unity has overridden the == operator but I suppose it works? like if you set it to null yourself

cedar ledge
#

saved me time, especially when dealing with code that runs in OnValidate()

#

since Start() doesn't run in the editor, obviously, things can be null all the time

fresh salmon
#

NRT is just the compiler "doing more" so it outputs warnings on the null state of objects, and nothing else. It's not to be confused with the null-* operators

cedar ledge
#

also i think it's just best practice to have the compiler warn you about things being null and making you think about it

#

it also helped remind me to parameterize my functions

#

which creates more modular code

fresh salmon
#

But yep, I'm surprised NRT can be enabled with that "null-ish" state Unity introduces due to the object lifetime cycle

cedar ledge
#

i dont have to null check a variable everywhere if the actually functions take a normal reference type, but then in Update() or whatever i use the nullable reference type field and do one null check

#
private void LateUpdate()
{
    if(target == null)
    {    // don't move camera if no target exists
        Debug.LogWarning("Camera target not set");
        return;
    }
    if(c == null)
    {    // don't move camera if no camera exists
        Debug.LogError($"No camera component on {name}");
        return;
    }
    Reposition(target, c);
    Resize(target, c);
}
#

so then I don't need to null check target and c inside of Reposition and Resize

#

before i used nullables, i didn't have parameters on those functions. still works perfectly fine, of course. I just like how it made me make the functions more modular and not assume as much

fresh salmon
#

Yep, it sometimes makes the code more convoluted with all those null checks, but for good

#

You can't pass something that can be null, into something that cannot, without noticing

cedar ledge
#

if you're doing the same null check in multiple places, especially if they are sequential (but in different functions) maybe you just need to make that function take a parameter instead, or make them work on the same null check somehow

cedar ledge
#

forces you to acknowledge it and handle it. what does it mean if this is null

fresh salmon
cedar ledge
#

❤️

regal olive
#

Is there a way to profile the Update() method of a single script?

#

Or timing it?

mint sleet
#
        private void SendPointRequest()
        {
            GeoPointExperience.TopLeft topLeft = new GeoPointExperience.TopLeft
            {
                lat = 10,
                lon = 1
            };
            GeoPointExperience.BottomRight bottomRight = new GeoPointExperience.BottomRight
            {
                lat = 10,
                lon = 1
            };
            GeoPointExperience.PinLocation pinLocation = new GeoPointExperience.PinLocation()
            {
                bottom_right = bottomRight,
                top_left = topLeft
            };

            GeoPointExperience experience = new GeoPointExperience(pinLocation);   
        }``` 
Hey! It is interesting. I can not reach my "experience" object at all from inside of a function.
#

any idea? thnks

stable spear
#

@mint sleet that's a private method

#

er wait

#

Are there any compilation errors in GeoPointExperience?

devout hare
#

Not sure what we should be seeing there?

iron pagoda
#

Hello. Is there a proven way to fix classes that may have become corrupted in the project?

mint sleet
#

I am trying to make an object to convert it into JSON

#

that objects uses different classes.

#

the structure is:

#
  public class MatchAll {}

        public class Must
        {
            public MatchAll match_all { get; set; }
        }

        public class TopLeft
        {
            public double lat { get; set; }
            public double lon { get; set; }
        }

        public class BottomRight
        {
            public double lat { get; set; }
            public double lon { get; set; }
        }

        public class PinLocation
        {
            public TopLeft top_left { get; set; }
            public BottomRight bottom_right { get; set; }
        }

        public class GeoBoundingBox
        {
            [JsonProperty("pin.location")]
            public PinLocation PinLocation { get; set; }
        }

        public class Filter
        {
            public GeoBoundingBox geo_bounding_box { get; set; }
        }

        public class Bool
        {
            public Must must { get; set; }
            public Filter filter { get; set; }
        }

        public class Query
        {
            public Bool @bool { get; set; }
        }

        public class Root
        {
            public Query query { get; set; }
        }
    }```
#

@stable spear

#

and this is the constructor :

#
   public GeoPointExperience(PinLocation pinLocation)
        {
            GeoBoundingBox geoBoundingBox = new GeoBoundingBox();
            geoBoundingBox.PinLocation = pinLocation;
            
            Filter filter = new Filter();
            filter.geo_bounding_box = geoBoundingBox;

            MatchAll matchAll = new MatchAll();

            Must must = new Must();
            must.match_all = matchAll;


            Bool boolOB = new Bool();
            boolOB.must = must;
            boolOB.filter = filter;

            Query query = new Query();
            query.@bool = boolOB;
        }
stable spear
#

I can't make any sense out of those fragments. can you paste the entire file somewhere? (preferable a paste-bin like site)

mint sleet
#

I solved it.

#

it was my mistake. an obvious mistake, that I wrote yesterday night.

iron pagoda
#

Solved mine as well.
Need to remember to let all the methods get up-to-date game objects from scene :)

misty crescent
#

Hey guys, any tips on how I can control the movement of a cube based on where I drag my mouse?

#

The problem I'm seeing is when I drag from point X to point Y, it (mostly) is correct but it's not perfect. Sometimes it doesn't apply enough force at all, sometimes it does not go in that direction. Any pointers on how I can make this better?

stable spear
#

How are you generating the force vectors?

misty crescent
#

@stable spear

    {
        Vector3 dragVectorDirection = (eventData.position - eventData.pressPosition).normalized;
        Vector3 offsetDirection = new Vector3(dragVectorDirection.x + 0.45f, 0, dragVectorDirection.y + 0.45f); // adding offset since isometric. not sure if correct.
        
        cube.GetComponent<Rigidbody>().AddForce(offsetDirection*magnitude);
    }```
stable spear
#

looks like you're converting the 2d vector into a 3d force vector without any real interpretation

#

Depending on what you want, there are many things you could do instead:

  1. Make the block glued to the ground so it doesn't rotate, and then slide it around the surface with the mouse.
  2. Project the mouse to a point on the floor (using Raycast), and then create a force pushing the box towards that point
  3. As the user moves the mouse, generate force vectors by raycasting the starting and end points onto the floor, and then taking the difference.
#

#3 is probably closest to what you have, but it would be more physically realistic

#

But maybe #2 is what you really want? I dunno. Up to you

misty crescent
#

No, not #2. Because I should be able to swipe anywhere on the screen, and it should be able to fetch me the direction vector in world space (endPosition - startPosition). The cube can be anywhere on the map, doesn't matter

#

Basically, if I swipe from the bottom right to the top left of the screen, a direction vector should be constructed that's appropriate to the game's world space and the cube should use that for the AddForce() call

stable spear
#

what do you want to happen if the user drags the mouse around, but not on top of the cube?

#

do you actually want the cube to stay under the mouse as much as possible?

misty crescent
#

no, I want to apply a force of fixed magnitude on the cube, but direction is based on direction of swipe

stable spear
#

You can use Camera.main.ScreenPointToRay to generate world-space rays corresponding to each mouse position

misty crescent
#

One more thing to note: I don't care about the Y axis. Ideally I will freeze position/rotation on Y

stable spear
#

And then floorCollider.Raycast(...) to raycast those onto the floor

misty crescent
#

so the ScreenPointToRay calls to construct the vector3 must discard the y axis i think

stable spear
#

(you need to get the floor's collider)

#

no..

#

ScreenPointToRay generates a ray in world-space. Imagine if the mouse were a little hand in the game world shooting a laser directly towards the direction the camera is facing.

#

A ray is a Vector3 origin and Vector3 direction

#

One you have that ray, you can cast it onto the floor collider

#

And get a point on the floor

#

that point will have y=0, assuming thats how the floor is oriented

#

Given two points on the floor, the difference gives you a force vector perpendicular to the floor

#

And it will be properly scaled for the perspective that the camera is in

misty crescent
stable spear
#

yea

#

You could make a helper function so you only need to write that code once

#

The code that projects from the mouse position to the floor position

misty crescent
#
        var c = Camera.main.ScreenPointToRay(eventData.position);

        floorCollider.Raycast(b, out var hitInfo, 5f);
        floorCollider.Raycast(c, out var hitInfo2, 5f);
        
        hitInfo.point```

is hitInfo.point what I'm supposed to be accessing?
stable spear
#

yes

#

you gotta handle the case where it doesn't intersect the floor

#

Actually, hm

#

In that case you can still do the projection, it just needs to be done manually. But you can try this to see if it works the way you want first

misty crescent
#

I just get a (0.0,0.0,0.0)

stable spear
#

can I see your code?

misty crescent
#
        var c = Camera.main.ScreenPointToRay(eventData.position);

        floorCollider.Raycast(b, out var hitInfo, 5f);
        floorCollider.Raycast(c, out var hitInfo2, 5f);
        
        Debug.Log(hitInfo.point);
        Debug.Log(hitInfo2.point);```
stable spear
#

5f may be too small

#

you need to check the return value of Raycast

#

if either one returns false, cancel the drag (that means it went outside the floor)

misty crescent
#

yeah I get 2 vectors now

misty crescent
stable spear
#

yea

misty crescent
#

and that happens to be my direction vector that I use to move the cube?

stable spear
#

sure. you may need to scale it by some number to get it the right magnitude

#

using AddForce, I suggest using ForceMode.Impulse

misty crescent
#

why ForceMode.Impulse?

stable spear
#

I believe the normal AddForce is scaled by fixedDeltaTime first, because it assumes you are calling AddForce() every frame (every FixedUpdate). And thus if the framerate is different, it needs to be scaled

#

But a single big force applied to an object does not need that.

#

That's what Impulse is for

misty crescent
#

got it

#

So it seems to be working well but there's a small issue

#

After a while, both vectors resolve to the same value and thus no force is applied (because the difference is 0)

stable spear
#

after a while?

misty crescent
#

let me send u a recording

#

do you see how after the first time I do this ,both the ray's vectors start resolving to the same valjue?

stable spear
#

It looks like it isn't working cause the end of the drag is no longer on the floor?

#

if you're careful to keep the mouse over the floor, does it continue to work?

misty crescent
#

spot on

#

and now it works like a charm!

stable spear
#

this can be fixed by replacing the floor collider projection with a manual projection

#

something like...

#

one sec

#
private Vector3 ProjectOntoFloor(Ray ray) {
  float t = -ray.origin.y / ray.direction.y;
  return ray.origin + t * ray.direction;
}
#

instead of floorCollider.Raycast do Vector3 bPoint = ProjectOntoFloor(b);

#

and same with c

misty crescent
#

that works as well 🙂

#

thank you so much for the help. times like these is when I wish I could tip someone on the internet with crypto or something

stable spear
#

I should put a tipping address in my profile, heh. I wonder if that's allowed.

regal olive
#

Which way should I go:

  1. Make an empty GameObject child and use it as a handle, supplying its transform.position in child component scripts
  2. Make an editor script with Handles.PositionHandle() as per https://docs.unity3d.com/ScriptReference/Handles.PositionHandle.html and use the serialised position field/property from the runtime script in other scripts
stable spear
pulsar isle
#

Let's say I have a video and play it as a video texture. I know the video.FrameCount. How can I seek to a specific frame of the video ? Like let's say I want to get to the frame no# 50 of the video.

#

Oh apparently I can do videoPlayer.frame = 50 and get to the 50th frame.

regal olive
#

To rephrase: which is more lightweight, a GameObject or an Editor script?

#

probably the latter

stable spear
#

for doing WHAT? You aren't making any sense

#

we're not telepathic

regal olive
stable spear
#

I'm familiar with that function. But I don't know what you're trying to do with it

regal olive
#

Well, since it doesn't seem obvious – I wanna make a handle like you get by default for objects (the coloured axes with arrows pointing out that you can move around?) and use it.

stable spear
#

You are writing an editor extension specifically?

modest lintel
#

You wanna do that in a build? Or Editor? Handles is a Editor only class

regal olive
#

I usually make a child game object (for convenience and adjustment in local coord space) and supply its reference to scripts which need its position

regal olive
modest lintel
#

Well if its Editor only your concern shouldn't be "lightweight"

regal olive
#

I figured out that it's not what I'm looking for since it sticks in the same place. In my case, I want to get a muzzle point for a gun to fire, which needs this muzzle point to follow the gun – easiest done with a child game object.

stable spear
#

I don't think you understand what this function does

#

Just use a gameobject

regal olive
#

it's not what I want, as I said

regal olive
modest lintel
#

One gameobject, in editor is a miniscule difference

regal olive
#

I see. Okay, I'll not worry about it so much.

#

I have gone into a micro-optimisation route, which is quite novice of me 😥

stable spear
#

If you're actually making a custom inspector on a custom component which specifies the muzzle point for a gun to fire, then it would make sense to use Handles to draw and manipulate the muzzle point, and store the value back in the serialized component

#

But if you're advanced enough to do that, I'm not even sure why you'd be asking this question.

#

It would be slightly more efficient than having an extra game object, sure

regal olive
#

Yes, I would've made a custom GunEditor for my Gun and used it – really did it too, just a while ago.

regal olive
#

There's also the part where I'd transform the point I got back from the Handles.PositionHandle in the gun's local space and all that but perhaps making a game object is just easier at a slight cost which I shouldn't even bother about unless I'm rendering thousands of guns.

stable spear
#

Next time you gotta say what you're using it for. Otherwise, there's no way to connect the dots

regal olive
stable spear
#

I did read it very carefully. It still doesn't make sense, by itself. It makes sense to you because you know what you're trying to do

regal olive
#

Alright, I should've given the use case and perhaps some code for clarity with the question.

#

Sorry for the trouble! 😅

full cave
#

hey does anyone know how to add test ads of unity in a game. please help if possible. There is some errors in the script i imported,
saying gameId and mySurfacingId not found in the current context...pls help!

undone coral
#

i have a super polished version of this, and i can reference it in helping you

#

my #1 recommendation to improving your ability to implement a UI interaction like this is expressiveness. you should use unirx

cobalt sage
undone coral
#

there are two ways that make sense to move a rigidbody using your finger - one is kinematic movement, and the other is to use a joint between the finger and the object

cobalt sage
undone coral
#

with kinematic movement, the object stays attached sharply to the finger, so it has good feel in terms of how it can be controlled, but you must interpret the finger movements, over time, to calculate a velocity (i.e. the momentum) to give the object you're manipulating

#

using a joint, the object feels like it's attached to the finger with a spring, so there's a "latency" between moving your finger and moving the object. the physics system naturally imparts momentum to the object this way.

#

@misty crescent does that make sense?

undone coral
#

which sounds like a rigidbody

cobalt sage
#

oh okay i only scimmed over the chat

undone coral
#

it's pretty obvious from the video that the solution the user adopted is... bad

cobalt sage
#

tbh 90% of the stuff i see in this channel is bad..

undone coral
#

it doesn't behave naturalistically at all

#

it is a poor implementation of the kinematic movement option

#

so this is just the physics of how to achieve what you want. in terms of the parts, you have something that turns 2d screen positions into a 3d position of where the finger is ("raycasting"), and then something that turns those positions into motion ("physics")

#

there are a lot of approaches for raycasting

#

in my opinion, the ones that make the most sense are

  • casting to a plane local to the object you're moving, like the local xz plane
  • casting to a world plane, like the xz plane
  • casting to a view plane, like the camera xy plane, at the depth z of the object
  • casting along a custom built geometry of colliders, like an offset from a background cyclorama
#

there are a few more considerations: should it work with multitouch? what happens if the pointer goes off screen?

#

it's really tricky to do the raycasting right - you're turning 2d dxy/dt movements into 3d z-y-z positions, which has a really simple approach in math terms. if you don't know the math, you're going to introduce a ton of really nasty and frequent bugs, when the 3d position changes way more than the 2d movement does

#

you can use a word like "manifold" to describe this

#

a lot of really nice motions, like dragging something along the surface of a sphere collider, allowing it to go behind the sphere, is impossible to do without understanding what "manifold" means

#

you might also want to mix and match planes and colliders

#

i'm not 100% sure why unity doesn't provide these interactions. my feeling is they themselves do not know how to do them 100% right. they are really hard

regal olive
undone coral
#

not in my benchmarks

#

i don't really buy into a lot of performance woo. i don't think i've ever experienced a slow down caused by any non-rendering code i've ever written, ever, with the exception of maybe using Rayfire and a word game that had a large trie to load

#

over 10 years of doing this

regal olive
#

Besides, in support of what you just said, I haven't thought of any use-cases where I'll be performing the 2D to 3D mapping calculation on several millions of surfaces at a time.

undone coral
#

okay, and maybe one really, really weird interaction with nested coroutines, where if you use them, you lose a frame unless you iterate the IEnumerator yourself

undone coral
#

i am advocating for help you design something nice 🙂

regal olive
#

I agree. Btw the code you shared is with the UniRx framework right?

undone coral
#

yes, but it doesn't do that much work

#

it's super high level

#

most of the knowledge in there deals with multitouch and moving the pointer off screen correctly

#

observe it does not use OnDrag for anything

#

it's so painful to do the move in OnDrag because pointers that move off screen and back on screen act weirdly

#

i use new input system which can also be pretty painful to deal with, but not that bad

regal olive
#

yikes, not good for planning borderless window interaction

undone coral
#

or like, just using it in the editor

regal olive
undone coral
#

here's everything

#

i think the gizmos don't render right but everything else works

regal olive
#

anyhow I'm not experienced enough to comment on that atm, haven't ever used this framework and I'm still quite a fledgling

undone coral
#

you can look at the source i shared and see some really small detail stuff

#

and some really big stuff

regal olive
#

why don't you make your gist into a full UPM package repo?

undone coral
#

because i wanted to do this in 5 seconds not 5 hours lol

#

someday

regal olive
#

it took me under an hour to make my first local UPM package, and the advantage of making it open source is significant

undone coral
#

i think i'll have a small package as part of the software i write

#

to let you stream unity to phones consoles and computers

#

this is used as part of some other technology i develop

cobalt sage
#

is that already a unity feature tho?

undone coral
cobalt sage
#

swear it was with there mobile app

regal olive
#

Unity Remote exists but I don't rely on it at all

#

last I used it (a few years ago) it left me wanting more

cobalt sage
#

@undone coral looking through your github im guessing you had to use java for your college/uni as well lol

regal olive
#

<java-rant>

cobalt sage
# undone coral yep

almost finished my last year of my bachelor got no more programming subjects haha just project management stuff rip

#

can't say i wanna use java more then i have to after this tho haha rather microsofts java

#

😆

regal olive
undone coral
#

yeah you still need to fill in some stuff there

#

i think i always configure it completely

#

and rely on the assertions

#

to tell me what i forgot

#

until i write a real editor component

#

this will only work with new input system though

#

i also have no idea if it works with a mouse since the multitouch changes i made yesterday

#

it should, but it might try to work only with the right mouse button

#

it does not work with a mouse right now* @regal olive lol

#

sorry... i gotta fix that

#

just touch press control needs to be button control

regal olive
#

yes, the Local Transform you take as an arg isn't being used

#

I also see a lot of bools, maybe you can use a flags enum instead

undone coral
#

yeah

#

any button will do

#

anyway

#

someday i'll package it

#

i think this is more for learning

#

particularly how to drive a joint

regal olive
#

looks good!

undone coral
#

yeah it should work now, sorry about that

misty glade
#

~~I'm doing some hula hoops with vectors and world/local positions, and just came across Transform.TransformPoint and InverseTransformPoint(). facepalm_picard

Are there any helper methods for "contains point" in transform? I couldn't find any. I can write my own, obviously, but I don't want to reinvent the (admittedly small) wheel again.~~

#

~~Hm.. it looks like I did invent the wheel a while ago, when I was first starting out. Is there anything that does this native to unity, or is this.. OK? I make no claims as to the quality/correctness of the below...

        public static bool Contains(GameObject GameObject, Vector3 Vector)
        {
            Assert.IsNotNull(GameObject.GetComponent<RectTransform>());
            Vector3[] leftV3 = new Vector3[4];
            GameObject.GetComponent<RectTransform>().GetWorldCorners(leftV3);
            float leftRectX = (float)(leftV3[0].x);
            float leftRectY = (float)(leftV3[0].y);
            float leftRectWidth = (float)(leftV3[2].x - leftV3[0].x);
            float leftRectHeight = (float)(leftV3[2].y - leftV3[0].y);
            Rect leftRect = new Rect(leftRectX, leftRectY, leftRectWidth, leftRectHeight);
            if (leftRect.Contains(Vector)) 
                return true;
            else 
                return false;
        }
```~~
summer pulsar
#

Hey guys

#

I have a question about Asset Bundles, If I have two separate projects, one for creating DLC (A) and the other the main project (B). Can I create an Asset Bundle in Project A and then, create a bundle. Then after creating the bundle, load it in Project B? Right now this doesn't work for me using Addressibles

undone coral
#

the addressables pattern expects you to use the same project to create extra content, because it adds information to an manifest file that helps the client make sense of what is inside that particular group of files, i.e. the addresses themselves

undone coral
#

this sounds fine

#

there's a really good sprite outline asset

undone coral
summer pulsar
# undone coral what is the objective

The objective is to have a designer, work on a separate project and produce content that ends up in prefabs, like clothing. Then for my project to load that asset from the bundle

undone coral
#

i think just have the same project if you want to use addressables

modest lintel
#

I'm not savvy with the details, but we load bundles made from a separate project just fine into the main project

summer pulsar
#

@undone coral so it turns out that this works well with assetBundles lol

#

so I am gonna use that because addressable is pretty complex

#

and fails like 90% of the time

spice maple
#

Is it possible to roll my own ECS system in unity without DOTS?

#

and by "possible", i mean if there will be a similar increase in performance

untold moth
livid kraken
untold moth
#

Yeah..

odd veldt
#

how to open this profiler window

austere jewel
#

Then if it's in hierarchy mode, switch it to timeline

odd veldt
#

how to read this ?

safe whale
#

Heya, I'm trying to use PrefabUtility.RevertPropertyOverride(), and by following what Unity Documentation says, I wanna get a SerializedProperty from a SerializedObject (which is a TMProUGUI)

I have my SerializedObject, but when trying to get the property with SerializedProperty textFont = serializedText.FindProperty("font");, it returns me null

When inspecting my object with the debugger that property exists but maybe am I trying to get it wrong ?

austere jewel
safe whale
#

Thx a lot !

austere jewel
#

You can look at the source. It's in the package

safe whale
#

I'm a hundred percent sure that my prefab's property is overriden here, and I'm trying to get rid of that override, but it just tells me that there's no override and it's doing nothing

#

Am I missing a hierarchy thing ? here's what I'm modifying

zinc bough
#

Hi! I'm looking to integrate Fastlane for the iOS build of our game. For that I need to be able to build from the command line, but have problems finding good docs and/or examples for how to do it with Unity 2020.x. We don't want to use the cloud thing, just build the project from the command line.

#

Apparently you need to build the project using C# code, but I can't find anything proper in the form of docs.

quiet minnow
#

but when call the ssm it throws me a null error. even in a debug.log

#

i think its because i set Static SkillSystemManager ssm. what do i need to do in that case?

fresh salmon
#

Have you ever assigned a value to ssm? If not, the error is expected

quiet minnow
#

let me check

#

actually i only read from ssm

#

i assigned some variables there

fresh salmon
quiet minnow
#

yea

#

same

fresh salmon
#

Same?

quiet minnow
#

thats my complete methode

#

and got same null error

#

i think its because of static

fresh salmon
#

No, it's because you never assign a value to ssm

#

It's not related to whether it's static or not

quiet minnow
#

damn

#

your right

#

what a newb xD

#

thank you

fresh salmon
quiet minnow
#

yea sorry 🙂

leaden jungle
leaden jungle
# spice maple Is it possible to roll my own ECS system in unity without DOTS?

why would you want to? There are a lot of things you can do to increase performance, I made a free asset update loop manager that basically you call all your methods from one update. It adds in some efficiency and also using managers, like instead of each enemy having a movement script you have a movement director that controls all enemies, that will also add a lot efficiency.

leaden jungle
livid kraken
drifting galleon
#

but if you find it too risky, you should definitely not put project time into it, like unity recommends

spice maple
#

i am taking other measures too of course, but ECS could give a nice boost

leaden jungle
# spice maple Bullet hell game

I meant why would you want to write your own, would probably be a lot less work trying to figure it out in it's current form then start from scratch.

spice maple
#

i enjoy lower level engine dev stuff tbh

#

yes, it's less efficient but also more fun...

leaden jungle
# spice maple i am taking other measures too of course, but ECS could give a nice boost

also if you use a manager to control all bullets it should greatly improve performance, the classic unity methods would have a script on each bullet so that the more bullets you have the more performance hit you get, but managing them all from one script will eliminate that issue. I wish DOTS was a bit more stable and straight forward myself, but there is a lot of other ways to add efficiency.

undone coral
#

you don't need to use assetbundles at all

#

unless this is a mod

#

if you just want someone to work on assets for you, that person can export the assets from their unity project by right clicking and choosing "Export to .unitypackage"

#

it sounds like you are only sharing assets at edit time

#

you wouldn't use asset bundles at all for that

#

or, share the files with visible metafiles turned on.

undone coral
#

you can see this in the docs

#

fastlane is not easy to use, and you will discover that instead of hitting File > Build

#

you're going to be fixing fastlane at least once a week

#

because something changes about uploading to the app store every 60 days on average

#

on AVERAGE

#

imo, you will not save any time

#

if you don't touch your project for ~90 days, you should expect uploading to the app store to be broken

undone coral
#

is my guess

misty glade
#

Any thoughts here on GitFlow vs Trunk-based branch process? For context, I'm an indie but we're looking to hire 2 devs in the next few months and.. I want to get my house in order ahead of time.

#

(my current model is trunk based, tagging releases as they're finished)

zinc bough
#

@undone coral I have used Fastlane for other iOS apps, and there it's usually a matter of xcodebuild and some parameters to set the project to build. Simple. With Unity it's weird that I can't just build the project in a similar way, or at least export an iOS project that can be built.

#

It's the -executeMethod part that has me stumped. I can't understand why I have to write an app to build an app.

thorny lintel
#

Can i clamp this so head wont turn 360?

junior sorrel
#

Hello,
I have implemented in my Unity project leaderboard using CloudOnce

I added all the code and the sign in seems to work when doing an internal testing

My issue is that when I submit a score, that score doesn't show up thought when I check if there's any errors I would receive no errors and when I try to load leaderboard data I would receive nothing.

Anyone had this issue from before with CloudOnce or even with out it?

undone coral
#

there is a command line option to export an xcode project, it's called -buildTarget iOS, if you don't want or need to customize anything about the output

#

is your goal to get this to work in CI?

#

you will have to deal with licensing

undone coral
#

even when you set up UnityYAMLMerge

#

for games imo you should work out of a develop branch for everyone, and then merge into a master branch that is your current release. your external devs will not merge their branches, it's too difficult, if you accept you'll have to do that now you'll thrive

#

so gitflow.

#

additionally you should use your own lfs server, i suggest the one from here - https://alanedwardes.com/blog/posts/serverless-git-lfs-for-game-dev/

#

with github you run out of transfer bandwidth instantly

#

git on windows has bugs with files larger than 4GB

#

that link gives you an aws cloudformation stack you can deploy, relatively low pain, and you check in the credentials used to access your LFS server into the repo and it Just Works

#

to make merging easiest, i recommend working out of prefabs

#

@misty glade
especially for stuff like scene layout, i suggest a model of the form

Root Hierarchy
 Level Layout Prefab
  Sharping Prefab 1
  Doctorpangloss Prefab 1
  Sharping Prefab 2
  ...add'l prefabs

If I need to modify your layout, I would create a prefab variant and substitute it in the scene

#

hope that helps

#

those additions would be prefabs*

#

i have had no luck with the git asset store plugins

misty glade
#

Cool - thanks for the feedback. I hadn't put too much thought into scene/unity work.. I was maybe hoping (dreaming?) that all the other developer work would just be in pure c# but.. maybe that's a pipe dream.

undone coral
#

like for visualizing a difference in the scenes

misty glade
#

It might still be doable for this project since the bulk of the work is on the C# side - the game itself is mostly lightweight UI

undone coral
#

it's exactly the same. nobody will need to modify those for singletons. for things that are genuinely instances it's painful

misty glade
#

Yeah, that's my current "policy" right now. TBH I kind of hate working in the Editor; although it does make setting up the objects quite a bit more work

undone coral
#

but for many scenarios you can set the values in the Instantiate caller, for example when spawning bullets

undone coral
#

that's right

#

for UIs it's very similar, you want to use the scene layout pattern

#

prefabbing out pieces of the UI and encouraging people to create a new prefab for their additions and a variant for changes

#

really it's so you can merge

#

you still need to merge in this scenario, in editor instead of in the command line

misty glade
#

In general .. my intent, were developers to be working in Unity, would be to make their own self-contained prefabs with scripts that accompany them

undone coral
#

this is better. you need to visualize what people did

undone coral
misty glade
#

In the .prefab files themselves?

undone coral
#

if they're making e.g. cards you can make sure they get the right "editing scene"

#

Project Settings > Editor > Prefab Mode > Editing Environments

misty glade
#

Hm, I'm not familiar with this/these settings.. will google up and brain download. Thanks.

#

Hm, OK. This is cool but I don't think necessary for our game. We're doing a lot of panels and cards (it's .. somewhat of a TCG) so the bulk of the work is in the C# - abilities, card interactions, etc. I still have to .. wrap my head around how I'm going to separate the work and integrate the results easily.

Perhaps this will be more relevant if we start doing art and/or content for each of the "cards" in our game that need specialized technical wizardry (particle effects and so on) - we could have a prefab environment "card template" and then each developer could be working on their own prefab (one card) within that scene

weak dome
#

How can I wait for user input using async/await? I can only find examples with Task.Delay().

tough tulip
weak dome
#

Thank you so much! Didn't know about UnityAsync.

compact ingot
summer pulsar
zinc bough
# undone coral is this for a game?

Yes, it's for a game, but not for CI. The idea is to get faster test builds out to the team by automating as much as possible using Fastlane and pushing to TestFlight. We have pro license of Unity.

zinc bough
drifting imp
#

im not sure if this is the right place to ask this, but is there a way to codesign or notarize something on a WINDOWS computer so that you can release an OSX version on steam? last i tried you needed a mac and had to get a special program i think

sly grove
#

Or at least OSX

drifting imp
#

son of a b, do you need to buy that Xcode program as well once you do have a mac?

sly grove
#

There are online services where you can rent a virtual mac for such purposes

sly grove
#

You do need to sign up as an Apple developer though, which costs $$$ every year

drifting imp
#

Is this something i would only have to do once for a game? like if i kept releasing new builds, would i have to rent a VM every time

sly grove
#

Sorry actually I misunderstood this all a little bit

#

YOu need a Mac if you want to build an app for iOS (iPhones) or for a mac on the Mac App store

drifting imp
#

oh, i should have specified my bad. my context is putting a MAC OSX build of my game on Steam

sly grove
#

if you want to build a standalone mac player I believe that you can do that from Windows, but there are some weirdnesses with the filesystems, and it's actually a little simpler to do it from a linux machine

distant pivot
#

So, a bit of information here. You could run MacOS in a VM, but Apple's licensing generally requires that you run MacOS (even on a VM) on Apple hardware. So if you're doing so for commercial purposes (and on the Steam store, I'd say that's yes), I'd be careful

#

Mac cloud rentals may be preferable if you don't want to have to buy the hardware

drifting imp
#

thanks for all the info so quick guys, ill look into these links

drifting galleon
compact ingot
drifting galleon
#

but because of that it also removes a lot of possible optimization of just plain async await. i don't see the point

#

it may only be useful if you are really only a beginner with async

compact ingot
#

it allows you to use the full unity API in async code without having to use coroutines

drifting galleon
compact ingot
#

plus it has a better synchronization context than plain unity async/await

#

what do you mean by normal async/await?

drifting galleon
#

imo it still has more drawbacks than usefulness. it's easier to work with for neewbies but it removes a whole aspect of async await AND you have to unlearn things when you want to switch AND your codebase can not easily switch to normal async await

queen plover
#

What parts of the Unity API are not able to be used in async?

#

Probably too many to list all, but any notable ones?

compact ingot
#

but there is a caveat

#

if you do for example async void Start() and use unity api inside an await-ed method in there, you are NOT using threads either, so there will be no complaints from the runtime

drifting galleon
compact ingot
#

why not?

drifting galleon
#

oh, no i understood it incorrectly. no of course you can use unity api in async void Start() and yes, that will not run on the thread but THIS is behaviour you WANT and is normal behaviour

compact ingot
#

its actually not normal as far as C# is concerned, its actually kinda special behaviour

drifting galleon
#

so that is default behaviour

#

and unity does not await async Start()

compact ingot
#

ofc it does

#

just not with thread in C# but deferred in the native engine

drifting galleon
#

cause if that'd be the case, unity api calls should break

compact ingot
#

error message when you call stuff from outside the main thread is dispatched by the native engine in the first place, so it has all the power to handle custom sync with await any way it pleases

#

it just can't deal with a user running stuff explicitly in a thread the engine has no control over

drifting galleon
#

you should never use any unity api inside an awaited method. even if it's awaited from async Start()

compact ingot
#

but why?

drifting galleon
#

because you want to DO work, OFFLOAD it and then APPLY it

compact ingot
#

thats something completely different

#

async is not for doing work

#

it is for synchronization of concurrent events

drifting galleon
#

you know what i mean

#

you get something back that you waited for, return it to where it is needed and then apply it. don't apply it inside where you are waiting for it

compact ingot
#

ah, ic what you mean

tough tulip
tough tulip
#

the behaviour is similar to IEnumerator Start, which is not yielded at start

tough tulip
drifting galleon
# tough tulip Don't know if this might help you or not, but you can wait for a task to finish ...

nah. it's not about a problem i had, just tangential referencing a previous discussion on this server. i hate coroutines. they are absolutely terrible imo. yes, they were a smart implementation of smth years and years back, but when async await was released it just superseded coroutines. that's why i am always against people telling beginners to use coroutines and in the discussion a statement popped up like 'if you want to use async await in unity you NEED unitask'. and no i said that that is nor was ever the case and now i just had a look at unitask and have reasons why you should absolutely NOT use unitask

compact ingot
# drifting galleon nah. it's not about a problem i had, just tangential referencing a previous disc...

btw. i'd like to make clear that i'm not advocating UniTask for everyone... it just does a lot of things like what malloc described in a neat package. If you know what you are doing, its probably best to use as few external libraries as possible. But i'd also be careful with blanket statements about the usefulness of UniTask and similar things. Maybe someone else finds them to be a perfect fit for their project.

drifting galleon
compact ingot
#

i dont see what that has to do with someone being a beginner or not

#

to make informed decisions, it is best to understand all available options

drifting galleon
#

probability is high that if you think the standard approach won't work for you, you may be thinking about your problem incorrectly

compact ingot
#

yes, very much so

#

btw, the reason why unitask was advocated so strongly in that original discussion was because unity does a Thread.Sleep(1) every time an async thing is scheduled, which may lead to unexpected performance degradation in some situations.

austere jewel
compact ingot
# austere jewel You can read about UniTask's justifications in this blog <https://neuecc.medium....

however that article does not discuss the threading issue that was the origin of the discussion. one might argue threads are just one way to implement async/await... but some have come to expect threads, and potential offloading to a different cpu-core, as something integral to async/await when used together with regular Tasks. UniTask relegates the Threadpool to one method and presents it as something dirty and wasteful.

austere jewel
#

I'd argue that most standard usecases for coroutines (which UniTask is mainly aiming to replace) are not necessarily actually being used to offload 'work', and are instead just being used as a cleaner way to represent program flow. If you want to actually perform work then I'd probably not recommend it.

undone coral
undone coral
#

I advocated UniTask so strongly because it offers some great semantics for games, where sometimes you do stuff that can be in the background, and sometimes you want to do stuff that’s Unity main thread only, and it provides a super elegant way to switch between the two contexts within a single async method

zinc bough
reef bloom
#

Can someone help me in integrating solona wallet in unity? I can't find any docs related to it.

topaz stone
#

Hi. Does unity scenes/assets have a hash that changes when the scene/asset changed?

tough tulip
topaz stone
#

mhh thanks for the hint, looking into it

fallen halo
#

also, i have seen in tutorials for 2d they draw a box collider every frame of the attack animation.
will it be any problem if i just do it in one frame of the whole animation with animation event. not using box collider but using a function that draws a overlapboxall

tough tulip
#

overlapboxall will allocate a new collider2d array everytime its called. you can also go with Physics2D.OverlapBoxNonAlloc which doesnt do any additional allocation.
but as for hitbox, no one can really help you with it, because there are too many other factors influencing it

full shore
#

Hey all, I'm having an issue with texture quality. Essentially my textures get quite pixelated when I change the resolution of the game window (happens in build too)

After some testing it seems it is due to the textures import settings being set to a value much higher than what is being displayed. For example, the render texture is 2048x2048 and when I change the resolution from 1920x1080 to 1280x720, it gets very blurry and jagged edged. Changing the texture size to 1024x1024 during runtime fixed this issue, but then looks poor for higher resolution displays. Is there an easy way to automate this? Otherwise ill just do it through code

small badge
full shore
#

They dont - this is what they look like

#

the latter e.g. the normal texture works, but not the render texture

small badge
#

Generating mip maps on the resource textures is worth a try, then; that will automatically generate smaller versions of them and the shader should intelligently pick the most appropriate size when rendering.

full shore
#

a 4k texture looks great for HD displays, but this is software and a 720 display is not unheard of. Thus the render texture would need to get dynamically resized to avoid the downscaling which I think is the cause of the bad pixilation (as changing it from 4k to 1024x1024 when I resize the view works)

#

oh, ok - lemme try that

#

I thought that was based on distance and had nothign to do with UI resolution

small badge
#

As I understand it I think both should affect it? As far as I know it will pick a mipmap level according to how fast the UVs are changing in screen space, which will be higher if the texture is closer to the camera or if the screen is higher resolution.

#

But it's possible I'm misremembering how the samplers work.

full shore
#

Yeh you're right - seems that was exactly what was happening

#

didnt have samples so it was trying to run some downscaling I imagine?

#

thanks for the help - ill research more into how this stuff works

fervent sage
#

Just want to confirm: If I use GetAssetBundle() with a version number, and save the returned assetBundle, when I access that returned bundle am I accessing it from RAM or disk? (a blog seems to say Disk)
Secondly, should I cache any files I get when I use bundle.LoadAsset() or is LoadAsset's speed negligible and I should re-load each time I try and grab the file? (Basically does LoadAsset decompress - and should I clear this cache on things like scene change?)

undone coral
#

is this for mods?

fervent sage
#

I don't see how that matters though, those Q's answers should have general best-practice answers

undone coral
# fervent sage I don't see how that matters though, those Q's answers should have general best-...

the behavior of GetAssetBundle() in terms of disk versus memory isn't specified in the docs. should it matter? the safest assumption is that everything that implements IDisposable is definitely in memory. you can also probably assume that anything that's a GameObject or derives Component is also going to be in memory. on android, the asset bundle is decompressed on a background thread; i don't know if on android it deserializes on the background versus on the render thread

the best practice is to not use asset bundles for those purposes, use addressables. anyway patching outside the play store is rarely worth it - there are only 100 games in the whole world where it may matter.

#

@fervent sage GetAssetBundle() will save the asset bundle to disk, notify you, and then load asset will decompress and deserialize

fervent sage
#

So I can do the same thing for desktop

undone coral
#

AssetBundle bundle = DownloadHandlerAssetBundle.GetContent(unityWebRequest); will decompress and deserialize to memory, you will not want to call GetContent twice

fervent sage
undone coral
#

unity web requests are disposable, so you will also have the asset bundle bytes in memory, but they will be not useful to you? i'm not sure

#

i wouldn't over think it

#

it sounds like it can give you some of the asset bundle's contents on demand, earlier than completing the download

#

that's what it sounds liek the purpose of all of this is

#

i mean, why unity made this API

fervent sage
#

sure, and for addressables, I just went with bundles because there were much better tutes on bundles but no good ones I could find for addressables doing what I need (reducing android initial build size)

undone coral
#

for "streamed asset bundles"

fervent sage
#

kk

undone coral
#

like card illustrations

#

is that 100% of the assets you want to download

fervent sage
undone coral
#

i understant it could be scriptable objects or whatever

#

okay, i would personally recommend just zipping those and downloading them, and updating the rest of the game via google play

#

asset bundles are very painful

fervent sage
undone coral
#

they just boil down to another binary, adjacent to google play

fervent sage
#

sure

undone coral
fervent sage
#

I've already implimented the bundle method so ill just go with that. What do you mean radioactive?

undone coral
#

it's better to just have your game not start until it downloads a zip file, unpacks it, and you load the images. and if you need more zip files, you can update the list of URLs and push a google play update

#

you don't want to stream this stuff, and you will never want to define e.g. the cards alongside the images

#

it will be radioactive to store anything but the images in the asset bundles, and then once you are only storing the images, you're reinventing a file system to reference them (like, what is the name of the sprite in the asset bundle and blah blah blah) - you will have just been better off getting a big dump of images

#

it's not useful to have a setup where you have broken references that aren't fulfilled until a bundle is downloaded

#

because you would have no way to tell the difference between that and a bug

#

like, a card missing its image

fervent sage
undone coral
#

okay

#

that's good

fervent sage
#

Uhu, well thanks

gusty gazelle
#

Hey guys! Quick question. My team and I are currently making a game (on the blockchain) and we are facing an issue/bug. Whenever a person logs in (with MetaMask), they can log in again and pretty much play on 2 + screens with the same login. Is there any way to differentiate/limit them to just one instance?

undone coral
#

there's also a package called Trimmer

#

you can author your own build method too:

static void Build() {
...
var buildPlayerOptions = new BuildPlayerOptions()
{
    extraScriptingDefines = new[] {"UNITY_ASSERTIONS"},
    locationPathName = destinationPath,
    scenes = EditorBuildSettings.scenes.Select(s=>s.path).ToArray(),
    targetGroup = (ios build target group),
    target = (ios build target),
    options = buildOptions
};
BuildPlayerWindow.DefaultBuildMethods.BuildPlayer(buildPlayerOptions);

}
#

etc etc

misty glade
#

(or deny the second login, whatever makes sense for your situation)

gusty gazelle
agile grove
#

hey can anyone tell my how i can do GameObject array in custom window editor?

plucky junco
#

ok so this has nothing to do with unity, but i know that it is used in unity a lot.
how can i get all workshop items, from a specific person (the active user specifically), and a specific game

#

my first idea was to go with something like this

UGCQueryHandle_t handle = SteamUGC.CreateQueryUserUGCRequest(SteamUser.GetSteamID().GetAccountID(),
                                                                         EUserUGCList.k_EUserUGCList_Published,
                                                                         EUGCMatchingUGCType.k_EUGCMatchingUGCType_Items,
                                                                         EUserUGCListSortOrder.k_EUserUGCListSortOrder_TitleAsc,
                                                                         AppId_t.Invalid,
                                                                         SteamUtils.GetAppID(),
                                                                         1);```
#

but i don't have much experience with Steamworks and how it works

#
// OPTION 1
SteamUGC.GetQueryUGCResult(handle, 0, out SteamUGCDetails_t details);
// prints all details out

// OPTION 2
SteamAPICall_t call = SteamUGC.SendQueryUGCRequest(handle);
onSteamUgcQueryCompletedCallResult.Set(call);
//onSteamUgcQueryCompletedCallResult just prints the callback
#

these are how i was trying to receive the results, but neither of them gave me what i wanted.

misty glade
# gusty gazelle Yes, that's what we also thought, but how?

Maybe I'm assuming that you're handling more of the backend then you are.. I don't know anything about "MetaMask" unfortunately... questions about how a specific library works aren't likely to be answered successfully in this discord, unless those libraries are pretty commonly used in the Unity universe, I suspect. It's certainly the first I've heard of it

plucky junco
#

nvm i figured it out

#

i had to use both

#

i queried option 2 till i got a result, then i run option 1 and it gives me what i want

regal olive
#

Hi again, so lately I've been trying to work with a KdTree in order to paint the vertex colors of my mesh, I'm using a kdtree to get the nearest vertices when my character collides to set its vertex color, that I then process into a shader to display the right textures for each vertices, but the behaviour I am getting is strange, it seems it only takes 1 out of 2 vertex which gives some kind of "strips" effects :

#

and finally my function that is called on Collision enter to set the vertexColors : ```public void SetWound(Collision collision)
{
if (collision.contacts.Length == 0)
return;
bool b = false;

    if(part == Part.HEAD)
        b = true;

    int[] vertices = ragdollController.pointVertices.GetClosestVertexIndex(collision.contacts[0].point, coloring.renderer, 0.0015f, b);
    coloring.woundedVertices = new List<int>(vertices);
    coloring.UpdateMesh();
    coloring.LateUpdateMesh();
}```
#

I think that the issue my be coming from the findNearestsK function in my KdTree.cs, more specifically because of the selector that either checks for the closest x or y value of my vertices, but I just can't get it to work to select ALL the closests vertices within range, how would I do that?

#

to cut it short, how would I find the vertices of my mesh within a radius using a KdTree/Octree?

#

if someone has an answer, please ping me

undone coral
#

it's sort of unnecessary for what you're doing though

#

you should retrieve the vertices by projecting and querying the UV map

regal olive
#

How would that be doing say, on Android platform with a mesh of roughly 6000 vertices ?

#

I mean performance wise

flint sage
#

Lookups shouldn't be slow (assuming correctly configured tree)

#

Generation might be a bit slow

regal olive
#

No the search is really well optimized especially for Android, the thing is, it just doesn't pick up all the vertices within an area as you can see in the picture

#

I am kind of a mess when it comes to mesh manipulation, could you provide an explaination on how would I retrieve the vertices using the uv Map? Is it expensive? Because it would kind of defeat my initial purpose that is not to loop through all the vertices using kdTree

gusty gazelle
zinc bough
flint sage
#

You have a source for that info?

#

Sure there's the "new" build pipeline

#

But it's not that much different, especially if you're not doing anything fancy

zinc bough
#

@flint sage No, I don't know when and what has changed, but many articles talk about using -profileName and that option can't be found.

flint sage
#

I've never seen an argument called profileName, chances are it's somethign custom

zinc bough
#

Could be. So much about Unity is about installing this and that extension.

flint sage
#

It's not but okay

zinc bough
#

What I'm trying to do isn't exactly rocket science. It's getting iOS and Android builds from the command line.

flint sage
#

You just gotta create a static method that calls BuildPipeline.BuildPlayer and then use executeMethod commandline arg and buildTarget

zinc bough
#

Hm

odd veldt
#

why hybrid renderer can render big scene open world scene ?

zinc bough
#

@flint sage That's more or less what I've done.

#
public static class Builder {
    static void PerformiOSBuild () {
        BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions {
            scenes = new[] {
                "Assets/Scenes/LoadingScene.unity",
            },
            locationPathName = "iOSBuild",
            target = BuildTarget.iOS,
            options = BuildOptions.None
        };

        BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
        BuildSummary summary = report.summary;
    }
}
untold moth
zinc bough
#

% /Applications/.../2020.3.19f1/.../Unity -quit -batchmode -projectPath /Users/chakie/Work/... -executeMethod Builder.PerformiOSBuild
Gives no output and errors, except a notification is shown that it failed due to compilation errors. I try to find something in ~/Library/Logs/Unity/ but nothing there refers to a compilation. The timestamps on the files are all from when I ran the command though, so it's the right place.

flint sage
#

Pass -logFile

#

Also, sometimes weirdly enough unity doesn't log the exceptions. Probably because it already knew it was broken

#

You can try deleting library/scriptassemblies

zinc bough
#

I nuked all the log files and now Editor.log is current.

#
using UnityEngine;
using UnityEditor;

public static class Builder {

    static void PerformiOSBuild () {
        var buildPlayerOptions = new BuildPlayerOptions {
            scenes = new[] {
                "Assets/Scenes/LoadingScene.unity",
            },
            locationPathName = "iOSBuild",
            target = BuildTarget.iOS,
            options = BuildOptions.None
        };

        var report = BuildPipeline.BuildPlayer(buildPlayerOptions);
        var summary = report.summary;
    }
}
#

Gives:

Assets/Scripts/Builder.cs(8,38): error CS0246: The type or namespace name 'BuildPlayerOptions' could not be found (are you missing a using directive or an assembly reference?)
Assets/Scripts/Builder.cs(13,22): error CS0103: The name 'BuildTarget' does not exist in the current context
Assets/Scripts/Builder.cs(14,23): error CS0103: The name 'BuildOptions' does not exist in the current context
Assets/Scripts/Builder.cs(17,22): error CS0103: The name 'BuildPipeline' does not exist in the current context
#

Seems ok to me.

flint sage
#

I mean yeah...

#

waht did you expect

#

You have to put editor code in an editor folder/asmdef

zinc bough
#

I had no idea I should expect that. Ok, now I know where to start reading up.

zinc bough
#

@flint sage @undone coral Got my build working now and Unity seems to have created a valid iOS project. Thanks for the help!

#

The thing I wasn't aware of was the "editor only" asmdef.

radiant wave
#

Hey! Just set up a mobile AR app. Used only standard AR assets by Unity. Simple plane detection + object spawning. I've set up the forward render in the graphic settings and described the camera usage.
AR functionality is working, planes getting detected and spawning works. But the camera feed stays black. I've checked the default AR camera and it's rendering to a solid black color. Is that on purpose?

limpid prism
#

Hi, i'm writing unit tests with the unity test framework and one of my tests loads a scene, the problem is, if i load the scene the playmode test stops and the scene i just loaded is played. Is there any way to make a "don't destroy on load" play mode test?

manic stump
#

https://www.toptal.com/developers/hastebin/exipuyonop.properties can someone help me add to this script to where each gun selected can have its own stored bullets array but then the current gun has its bullets array stored in a bullets array so it can show what bullets are left when a gun is selected. Cause i current have a bullets array show what bullets left but it shows the same bullets left for all guns.

sly grove
limpid prism
#

How can i do it? The game object with the play mode test manager is created at runtime

limpid prism
small badge
sly grove
limpid prism
sly grove
#

the question is do you have a way to get a reference to the object you're trying to preserve to call DDOL on it

#

If all else fails, I assume GameObject.Find would work to do so.

#

could be perceived as hacky though

limpid prism
manic stump
#

@sly grove are you able to help me a sec with my problem if it not too much trouble

fresh salmon
manic stump
#

sorry

tough tulip
fervent sage
#

If I use this:

UnityWebRequest request = UnityWebRequestAssetBundle.GetAssetBundle(info.bundleURL, info.bundleVersion, 0)

Is there a way to see if the request was fulfilled with the cache or by downloading?

tough tulip
fervent sage
#

mk thanks

fervent sage
hearty solstice
#

Need some help with Visual Studio with unity on Windows, my project loads just fine on vs code or in visual studio on the mac machine, however, for some reason, only this project i'm working on, whenever i open it via visual studio everything is with red lines, not even basic types such as System.Boolean is found

#

never had any similar issues, thoughts?

tough tulip
tough tulip
alpine herald
#

How can I make an animationClip with 4 box colliders with diferent offsets and sizes by code?
I managed to create animationClips by code for spriterenderers but i don't know how to make that for Boxcolliders
ObjectReferenceKeyframe .value doesn't work with the vector 2 of the offset like works with a sprite for example

fervent sage
#

I am testing downloading my assetBundles from Git in my editor but get the error:
** - The AssetBundle 'my URL' can't be loaded because another AssetBundle with the same files is already loaded.**
I assume this is because the assetBundles when built are somehow already loaded, but I can't seem to see any way to exclude them from the build?

#

I am using the AssetBundleBrowser

fervent sage
#

^ This happened on the first play and on none after. Will need to see if this will be a persistent problem on new builds or something

iron pagoda