5 ways to Reference GameObjects in Unity3D

Поділитися
Вставка
  • Опубліковано 16 лис 2024

КОМЕНТАРІ • 172

  • @JoMaFjErynMaLaZOr
    @JoMaFjErynMaLaZOr 4 роки тому +157

    0:00 Editor hook-up
    1:51 FindObjectOfType
    2:59 Singleton
    4:46 ScriptableObject
    7:12 Dependancy Injection

  • @bischoffdev
    @bischoffdev 5 років тому +108

    The right channel is missing because it is about mono behaviors.

  • @jonsmiff
    @jonsmiff 6 років тому +35

    Hey Jason, to fix the audio issue, you either want to make sure you are recording a mono track, or split the stereo track after it has been recorded. This can be done in Adobe Audition by selecting "Edit > Extract Channels to Mono Files". Or in Premiere, you can right-click the audio clip, select "Audio Channels" and set both the left and right channels to produce the left channel's audio.
    Great tutorial btw!

  • @stewartwood7577
    @stewartwood7577 3 роки тому +2

    Have been stuck on the wrong side of a stupidly wide Valley, a C# programmer just trying to get that Ahah moment on how Unity programmatically interacts between GameObjects. This great, to the point, clear and simple tutorial at a pace that doesn’t side track down rabbit holes is a blessing. Liked, Subscribed and Grateful.

  • @thenecromancer4113
    @thenecromancer4113 11 місяців тому

    i was moments from clicking off and then you said "injection" and it perfectly described the problem i was trying to solve. With a little phanagling, I got it to work, thanks to you!

  •  3 роки тому

    I was watching your video to make a script which checks if all enemies are dead.
    And you gave me ideas, thank you

  • @Tiagocf2
    @Tiagocf2 Рік тому +1

    This video is just perfect!
    is solved almost all issues i was having commimg from a programming background into unity. I still find referencing things through the editor very weird instead of just importing something into the script, but i loved the Dependency Injection method, very clean/optimized solution

  • @ash12181987
    @ash12181987 5 років тому

    I just found your stuff not that long ago, but everytime I run into an issue with Unity (I'm pretty new to it, and coding) your stuff seems to have the solution. Thank you for the good tutorials

  • @deyama2012
    @deyama2012 5 років тому +1

    Didn't think of setting prefab's type to anything other than "GameObject" before. The way you did it here, you don't have to use "GetComponent()" to call its "Initialize". Neat, thanks!

  • @valelelentin
    @valelelentin 3 роки тому +1

    So I've been pulling my hairs out while trying to find out how to reference in a ScriptableObject. Turns out you can't just do it the usual way, with drag and drop from hierarchy to inspector. Your second way, with FindObjectOfType works though. Thank you so much! Liked and subscribed.
    I hope if someone has this same issue, you'll notice this comment.

  • @meowl9329
    @meowl9329 2 роки тому

    Every beginner should watch this

  • @hantaakai8183
    @hantaakai8183 Рік тому

    Was wondering about these for the entire last week. Thanks a ton!

  • @Jamie-MrJam
    @Jamie-MrJam 5 років тому

    Glad to see that ScriptableObject GameObject references are fine to use. I thought doing it that way was abusing ScriptableObjects but I kept using them for references anyway since it felt right. I've been liking a mix of SO GameObject references and injections.

  • @Songfugel
    @Songfugel 4 роки тому

    Oh damn, as an old MVVM guy, would have been nice to see this video when I re-entered programming scene with Unity. I didn't think dependency injection was a thing in Unity, since every tutorial and guide so far have been using either the find or singleton pattern. This should really help my brain adjust to Unity better

  • @lee1davis1
    @lee1davis1 5 років тому +3

    Had to add this vid to my must watch list. Great tut

  • @PimpNick1980
    @PimpNick1980 4 роки тому +1

    Holy crap number four is a game-changer for me! Thank you.

  • @hegworks
    @hegworks 5 років тому +1

    Sometimes I wish I could like a video twice or more!
    I really appreciate what you did and since you said we can ask questions, I have one:
    Short story:
    How to reference GameObjects that a ScriptableObject Depends on (needs it)?
    Or
    How to assign GameObjects in the ScriptableObject itself?
    Long Story:
    I tried and tested all 5 approaches you mentioned on my own (surely bigger project!) and I was successful running it without any errors or warnings and achieved what I wanted from my codes, EXCEPT the ScriptableObject way;
    I can not find a proper way to reference to an object which my ScriptableObject depends on,
    I tried assigning it with the first method in the video but there was no way the editor could show me the Object I needed, so I could select it; Then I decided to make the object that I need a Prefab, but I was unsuccessful again; At last, I tried to assign that object in the OnEnable method you mentioned by using the second method (.Find) and it worked at the start of the game, but whenever I wanted to access to and change the object that my ScriptableObject depends on, during a run, it said the Object is not accessible maybe because it is destroyed and suggests that I should not Destroy it or check if it is destroyed before accessing it...
    Thanks again and sorry for the faulty English!

  • @moduntilitbreaks
    @moduntilitbreaks 4 роки тому

    Valuable information for the beginner. I find myself doing the direct reference, not anymore after this video.

  • @ZeroSleap
    @ZeroSleap 4 роки тому

    Wow i like this last one,it completely bypasses the hook-up from the editor which i hate,and is impractical it doesn't scale,plus it's something that can be used outside of unity!
    Just great!

  • @judgegroovyman
    @judgegroovyman 4 роки тому +1

    This is one of my favorite of your videos. Thank you!

  • @JeremiahNunn
    @JeremiahNunn 6 років тому +9

    You may want to cover using an event system as an alternative to needing references to specific objects or scriptable objects. Most likely, it's a combination of the singleton (event manager) and observer (score manager) patterns. In this case, the bad guy scripts just raise events with the event manager without needing to know or care about who depends on that info. The observers (in this case it's the score manager, but you could have other objects that care like an audio manager, ui element, particle effects, etc) listen for events without needing to know or care about who's giving that info.

    • @HariEdoTV
      @HariEdoTV 6 років тому +6

      I kinda feel the same way.
      Of the five here, I would probably go with scriptable objects as the cleanest, but I kinda don't like Unity's way of visualizing the instances as project assets instead of in the hierarchy. I wish scriptable objects were visualized in the editor as children of the automatic dontdeleteonload instance that appears in runtime or something.
      Events are cleaner yet, where the bad guy just broadcasts "hey, i got hurt 1hp by Player Red" and the score manager sees this and responds "that's worth 1 score point for Player Red". The bad guy should have no idea what score is earned, maybe the player red has an earn-double powerup. If you want to add a team-rally-manager it could also hear the same damage event and decide to earn rally points for Player Red's team. Keep the separation of concerns.

    • @AzazelezazA
      @AzazelezazA 4 роки тому

      @@HariEdoTV Hi. A bit too late for this but I liked how you described the event system in your comment. I'm kinda beginner/intermediate in Unity and I want to learn more about this implementation. Can you refer me some source or learning material with a similar narrative(like "bad guy broadcasts and score manager listens") as yours? I would really appreciate it.

    • @ssssssstssssssss
      @ssssssstssssssss 2 роки тому

      @@AzazelezazA A bit late, but it is the observer pattern. Search for OOP Design Patterns. I think rather than using a singleton event manager, you probably just want to just have the bad guys fire an event (static unityaction) and subscribe to that event

  • @SahilSingh-hc4fk
    @SahilSingh-hc4fk 5 років тому

    Jason is truly under-rated

  • @dago6410
    @dago6410 6 років тому +332

    my right ear gave this a thumbs down.

    • @Grempington
      @Grempington 6 років тому +11

      the beauty about gimmicky 7.1 surround adapters is that in cases like this you can just turn on the fake surround and voila - no missing right channel problem.
      still regret buying it though

    • @skorpius2029
      @skorpius2029 5 років тому +4

      for me left

    • @goldDEN1000
      @goldDEN1000 5 років тому +1

      @@Grempington You saved my life

    • @nosirrahx
      @nosirrahx 5 років тому +5

      I spent about 2 minutes going through my sound settings, always start with the simplest possible cause.

    • @DashMatin
      @DashMatin 4 роки тому

      same

  • @MaddinUndSo
    @MaddinUndSo 3 роки тому

    ive been looking for that for days now. thank you!

  • @SunnyApples
    @SunnyApples 6 років тому +45

    Hi Jason. Right audio channel is missing.
    By the way, I would love to know more about dependency injection in Unity.
    The only thing I know about it is that in the constructor, you would pass in dependencies, and keep your fields private, your properties read only if possible (to keep your object externally immutable). I don't know what the frameworks for dependency injection do, but I am aware of them existing (Ninject) - since I am beginner in C#.
    And since MonoBehaviour scripts don't use typical constructors, I am not sure how would this be done in Unity.

    • @aronlinde1723
      @aronlinde1723 5 років тому

      From what I have seen you extend the monobehavior class and add in the Dependency injection. So when you Instantiate it requires some object that passes dependancies in like arguments.
      More complex methods use subscriptions and events or a central object registry.
      I personally just like the Instantiate method being bolted on to MB components since it functions so much like we are used to with Prefabs. (Its not the same, but feel is better than actual)
      And if I am building concrete services than Singletons are the go to.

    • @MrCorrectify
      @MrCorrectify 5 років тому +6

      I highly recommend against using a DI framework in Unity. Its going to revolve around using a master class to inject dependencies, which not only obscures relationships for any team members that cant dig through code, but also requires you to maintain that long list of dependencies.
      A delegate event system for universal messages and simple Unity serialized field drag and drop injection for more direct relationships will keep your project far more decoupled, maintainable, and user friendly.
      Or in other words: need to add a point to the score? Send a "point scored" message out into the world. Let anything that cares do what it will (maybe the sound manager will be an observer, and play a cheering sound). Need player 2 to use a different input manager, or maybe you want to test a new implementation? Drag and drop the correct input manager into the slot in the editor.
      What you don't want to do is have to open up a class that has a long list of interfaces and hard coded connections to various scripts that you have to manipulate/add logic to in order to inject simple dependencies like the above.

    • @Songfugel
      @Songfugel 4 роки тому

      Sorry for late response, but I don't think you are using dependency injection correctly (or maybe I am mixing the concept a bit with a different model) if you are using it like that. The dependency injection model is actually meant to simplify and streamline the logic, validation away from the interface and who uses the data. And ofc. it should be used in conjugation with OnChanged events to propagate the changes from a centralized place to all subscribers.
      This approach allows you to create an extra layer of decoupling (used a lot it MVVM model in particular that is based on dependency injection of the ViewModel, that acts as an interface between the view and the model to make sure things don't break if view or the model is changed), so you can change the underlying database, storage system etc, without breaking anything in the actual program/game, and create the visual (view) part of the game, without caring how the data is actually handled, you just want to know what is the interface you connect to, and everything should work automagically, no matter where or how that underlying data is changed

  • @fluffyluffy884
    @fluffyluffy884 6 років тому

    Love the video as I was having problems with too many singletons and the injection method will solve some of my problems

  • @tonychristney2728
    @tonychristney2728 4 роки тому

    Some big gotchas with singletons in Unity are: remember to null out the instance reference in OnDestroy() and to mark the game object as don't destroy on load. If you don't do this, things can get messy with scene loading and PIE mode.

  • @dany19991
    @dany19991 6 років тому +29

    just as a curiosity , do you have games on playstore or appstore? any names / links ? do you have any books that you released or recommend ? thanks for making videos like this one :)

  • @wywarren
    @wywarren 6 років тому

    Unity has an internal thing right now that they use for workshops with a customizable editor window indicating steps in a tutorial. You can select any step and it will load a different "state" of the project. They essentially keep multiple copies of the project in a designated folder on the same folder layer as the Assets folder. That way you can jump to different states in a tutorial without having to name tutorial scripts with their step #. It's also useful for live tutorials when people join in late and have to start at a certain step and they can just follow along from that point instead of not being able to catch up due to the steps they've missed.

  • @pedrosousa6576
    @pedrosousa6576 6 років тому +11

    This was really informative, loving the regular content. Keep at it, it helps me out a lot. Thanks!

  • @crisdarklightning
    @crisdarklightning 6 років тому +1

    Really loved this one, it cleared my way, thank you!

  • @spiral9316
    @spiral9316 6 років тому

    Wow scriptable objects look like just sweet candy

  • @scort623
    @scort623 Рік тому

    Very good explanation and video.

  • @steveschreiner7444
    @steveschreiner7444 4 роки тому

    Thanks it was worth alone to just know about the method names

  • @stevevargas4687
    @stevevargas4687 4 роки тому

    VERY WELL DONE Jason!

  • @processor8267
    @processor8267 5 років тому

    I wish I could give more than one like. You are an awesome man.

  • @marcoseliasmep
    @marcoseliasmep 6 років тому

    Nice, many ways to do the same thing is always a good thing! Each one may be best for a different project usage.

  • @janiisdying
    @janiisdying 2 роки тому

    Thank you for this video.

  • @bubluubluuuu9253
    @bubluubluuuu9253 3 роки тому

    Nice tutorial. I would only add one small alternative to Singleton-> using static methods and static properties. Can be more adjustable than singleton in certain scenarios

  • @philberex
    @philberex 4 роки тому

    Thank u Jason this helped me allot.

  • @EmreUcan
    @EmreUcan 6 років тому

    Another great way is c# events and delegates. They are actually nearly best in this scenarios. Ofc in my opinion. Though injection makes sense to me. I love hard to break code and less editor interaction.

  • @NoFaceNoFace
    @NoFaceNoFace 5 років тому

    My left ear enjoyed thus.

  • @GrubPerez
    @GrubPerez 3 роки тому

    Very helpful!

  • @reed9269
    @reed9269 5 років тому

    thumbs up for the DI

  • @KoolakStudio
    @KoolakStudio 4 роки тому

    thanks jason you are perfect !

  • @Wendell-om3nq
    @Wendell-om3nq 3 роки тому

    Great video, helped a looooot BD

  • @rickloyd8208
    @rickloyd8208 5 років тому

    So much interesting ideas in one day :)

  • @Scenuable
    @Scenuable 2 роки тому +1

    I just wish you could use dependency injection in a constructor on a mono behavior

  • @kurok1132
    @kurok1132 6 років тому

    This video helps me a lot! Thank you!!!!!!!!!

  • @micaiahstevens8840
    @micaiahstevens8840 6 років тому +3

    AHEM - I am quite an expert, but like to see what others are saying. HOWEVER
    If your going to teach people to use FindObjectOfType; for the love of coding make sure to do it right. Add a local reference. Unity supposedly does a good job of cache that, but imagine hundreds of find object calls.
    And for a 6th way, I believe, similar to your Instance, you can just use a Static Variable, and/or function.
    Keep up the good work, regardless.

  • @beatsaway
    @beatsaway 6 років тому +3

    fantastic for noobs like me
    thanks x 10000

  • @TheNei
    @TheNei 4 роки тому

    Its is Very Usefull!!
    Thanks!!

  • @andremilanimartin3338
    @andremilanimartin3338 4 роки тому

    Thanks a lot for this explanation. Was really simple, good and showed all the code already written and working.
    The only problem is that Input.GetbuttonDown doesnt work for sevral buttons, since it activates all.
    Showing how to add a OnClick funciton via script instead would have been great, Since this would make it usable for UI and 2D UI based games as well.

  • @agerausten6630
    @agerausten6630 4 роки тому

    Hey man you are amazing

  • @ChrizSee
    @ChrizSee 2 роки тому

    Noice, my left ear liked that.

  • @buffoverflow
    @buffoverflow 4 роки тому

    What about events? Right now my preferred method is by using an event bus... Its not exactly a reference method, but a communicate method... its beautiful... pure programming magic :D

  • @gmaheuxdev5349
    @gmaheuxdev5349 6 років тому +1

    You are the best

  • @THEspindoctor84
    @THEspindoctor84 3 роки тому +1

    great video, thank you! Since you asked, I do have one question, fairly beginner unity dev here.
    In what situations is it preferable to use a script to assign classes to variables, versus doing it in the editor itself just by dragging and dropping? When I drag and drop stuff into variables, it kinda feels like the easy way out, but is it actually better sometimes?

  • @valeriopavan
    @valeriopavan Рік тому

    Hi there Jason... about the naming convention... does it proper to say the first method is 'direct' and all the others 'indirect'? Thanks :)

  • @onesevenfourone
    @onesevenfourone 6 років тому +1

    So what is more performant, in the case that you have 30 to 100 classes, which each one only have one instance and you are going to be calling them from other classes multiple times in runtime, FindObjectOfType or Singleton?

  • @renzeldayrit1943
    @renzeldayrit1943 6 років тому

    Could you do explain more about the last method? That was very cool. Thank you

  • @elirannissani914
    @elirannissani914 4 роки тому

    LOVE YOU SO MUCH MY BOY :))))))))))

  • @vasylynablahodyr3232
    @vasylynablahodyr3232 6 років тому +1

    What do you think about just sending event system from object or whatever you want, to score manager? You also can create interface with such event and just implement it on different objects, which can change score. Thanks.

    • @Unity3dCollege
      @Unity3dCollege  6 років тому +1

      Great idea, did a video on it today :)

  • @thealonely2639
    @thealonely2639 4 роки тому

    Great Keep It up

  • @foreignwarren7361
    @foreignwarren7361 2 роки тому +1

    Hi Jason, can you also make a video on how to reference components on other game objects from a script on a prefab. You cant just drag components onto a script thats in a prefab. I find it very confusing.

  • @DanieleScali
    @DanieleScali 5 років тому

    Well done

  • @Wendell-om3nq
    @Wendell-om3nq 3 роки тому

    Jason help me out, where did I put the variables that will be need in all scenes like level,xp,items on inventory? By now Im using a script with dont destroy on load but I imagine that there’s a better way...

  • @kiPROBRos
    @kiPROBRos 3 роки тому

    Excelent.

  • @random_precision_software
    @random_precision_software 4 роки тому

    Hi Jason,I have a music player that lets you lets you play next and previous track, stop and mute, with current track name and time left. I have multiple levels so I put a do not destroy on load on it. Yes the music plays, but it doesn't bring in the ui text from last scene..so I can't change the track etc. How would I get round this problem?..thanks

  • @benniegant
    @benniegant 4 роки тому

    Oh, wowwwwww Bruthah, I needed to here what you said about injections and Scriptable objects, I just started with unity recently. I have had NO CONFIRMATION I was doing things the right way or classes just self education. to bad self education lacks confirmation. The bonus part of what you said; " takes a little bit more brain power!". That statment made me feel Awesome, that I understand the way they work with one another. They have a crazy learning curve for sure and can almost feel like playing a game of chess makes you feel when you know your beat. They to take a bit more of creativity in thier usage as a project implementing scriptable object grows larger. THANK YOU SO MUCH, IM GONNA SUBSCRIBE AND BINGE WATCH ONLY YOUR CHANNEL FOR A WHILE. THIS IS MY NEW PEER GROUP

  • @badjano
    @badjano 5 років тому

    you should probably use "DontDestroyOnLoad" for singletons

  • @victor1102
    @victor1102 3 роки тому

    Thanks for the video! May I know what does the "this" keyword mean in this context? I only know "this" can be used in the class constructor, thanks!

    • @nikilkumar1000
      @nikilkumar1000 3 роки тому +1

      this always refers to the current class where you are using this.

    • @victor1102
      @victor1102 3 роки тому

      @@nikilkumar1000 Thank you so much!

  • @AutomationWithSholz
    @AutomationWithSholz 6 років тому

    Awesome !!

  • @clarkmeyer7211
    @clarkmeyer7211 3 роки тому

    is there a way to reference a child of an object by the child's name? I have a camera that is going to be used for aiming down sights of different guns but I need a way to make the camera move the a child of the gun so that it will position according to how I customize each gun's aiming view. This is for procedural guns that will have scopes that will vary in size and shape meaning I need to set a camera position for each scope variant. I would add a camera to each scope and then call the camera but that becomes problematic when multiple scopes are present in the scene.

  • @montz1757
    @montz1757 6 років тому +19

    will you cover the new c# jobs?

    • @axelman145
      @axelman145 6 років тому

      pleease!!!

    • @firnekburg4990
      @firnekburg4990 6 років тому

      That would be amazing !

    • @gregoryfenn1462
      @gregoryfenn1462 6 років тому

      Including installing and an explanation of how unity accesses and jobs, and where jobs are saved and defined on the system. The whole concept is blurry to me :(

  • @shanegibson9022
    @shanegibson9022 4 роки тому

    What about referencing a certain instance when I have multiple instances of the same object? How would you reference a particular one of those instances? For example, I'm making a dice game in Unity where I instantiate 5 dice with a for loop. I want to be able to sort those dice's positions based on the side value rolled. How would I reference a certain one that I need?

  • @MarcoCapelli74
    @MarcoCapelli74 2 роки тому

    6:57 Sorry but scriptable objects to change values at runtime only works when you play it in Editor. When you make a build out of it, it doesn't work. You can't actually change anything. So i'm a bit confused why you chose that as an example.

  • @neozoid7009
    @neozoid7009 2 роки тому

    Jason great tutorial but I didnt get how 1st method will not work for multiple bad guy??

  • @yizzie82
    @yizzie82 6 років тому

    Awesome video ad always :)

  • @Gers217
    @Gers217 4 роки тому

    Scriptable objects are good

  • @s.w.e.d.3057
    @s.w.e.d.3057 4 роки тому

    Any help with the following would be really appreciated:
    1. Getting a reference means you get that one object? meaning, If I instantiate Enemies and then inject them with a Health Script and I shoot one enemy or make a modification to either enemy do the Health on both changes?
    2. Is it better to have a prefab with components or a scriptable object with a reference to a prefab? An example would be a Heroes collector game or a pokemon game, where you would make a scriptable object of the type "Hero" and then plug in scripts for Health, Level, etc. or would it be better to have a prefab that has a reference to a scriptable object.? I am just really confused on the method behind creating a "Hero" or "Pokemon" since a ton of RPGs focus on party size.
    3. Does the reference gets copied or mimic? example, If I have reference to a List and My player gets a hero. I will add that hero to the List my player has of obtained heroes. But then, let us say in an stage the Hero fights another one of itself. will any changes I make to the player's hero be mimic by the hero in the List. How I think of it is this way(
    List hero
    gets a hero and now
    List playersHero = hero
    so that means if playersHero is the same as hero If I modify playersHero, hero has to change cause they are the same I am just referencing a reference....
    that is all. I am stuck at home so I gave myself until the Quarantine ends to make a portfolio and apply. I came across your Videos not long ago, maybe 2 weeks and I have been hooked. I don't get a lot of vocab but every piece of advice is great. I just wish I didn't miss your Q&A's. Unity is great and in the last 2 weeks, I have gotten over my fear of code. Thank you!
    also, I thought you were Dan Harmon for a while, especially in your newer videos.

  • @RayJ1216
    @RayJ1216 3 роки тому

    This is very helpful and well presented. I've been learning from a text that's presented the first 3 of your techniques, but without much context and no comparison.
    I learned from this how scriptable objects can give persistent scores. I do need that, as I will have multiple scenes and levels with scores and health. Clearly, scriptable objects, perhaps in conjunction with dependencies injection is an approach that works. Any downsides?
    But I'm unclear about whether any of the other methods can be made to work across scenes and levels, and how. You've said "not the first", but what about the two others? Can you expand on this?
    Others have talked about using a GameStateManager (like your scoremanager) with static fields and attached to something like the camera and that that will work across scenes and levels. Will it? Comments about this approach?

  • @jeremiahlampkey3137
    @jeremiahlampkey3137 6 років тому

    Hey Jason, are you going to be covering ECS at all? I'm looking through it myself and it seems like learning it will greatly help decouple and structure code. Also the performance is great =D

  • @hegworks
    @hegworks 5 років тому

    Sorry but here comes another question:
    Does using Var instead of the actual type of the Object have any benefits? (approach 5, in Instantiating the badGuyPrefab)
    Like:
    var badGuy = Instantiate(badGuyPrefab);
    VS
    ClickToKill4 badGuy = Instantiate(badGuyPrefab);

    • @PerfectlyNormalBeast
      @PerfectlyNormalBeast 4 роки тому +1

      No, var is just shorthand
      My personal rule is simple known datatypes should be spelled out:
      int three = 5;
      var three = 5;
      But when readability gets harmed and/or it's an uncommon datatype and the variable name is clear, use var
      var items = new Dictionary();
      Dictionary items = new Dictionary();

    • @hegworks
      @hegworks 4 роки тому +1

      @@PerfectlyNormalBeast Beside the fact that I already found my answer through these 5 months, your caring and answer is appreciated.

  • @bronzekoala9141
    @bronzekoala9141 5 років тому

    In this special case wouldn't it be the most efficient to just have ScoreManager be a static class with a static function AddScore()?

  • @rashidfarhan6223
    @rashidfarhan6223 5 років тому

    @ 5:28 What did you click or typed that lead you to the script?

  • @hamzabokh6626
    @hamzabokh6626 3 роки тому

    Hi , I don't want repeat (coins) When restart game please how do I do that , and thank you

  • @Kramlets
    @Kramlets 6 років тому

    My left ear enjoyed this.

  • @mikkeljensen3970
    @mikkeljensen3970 5 років тому

    Using the findobjectoftype is expensive right?

  • @БойкоАлександр-л7ф

    How do i pass a custom parameter to just instantiated object usung dependency injection (not using getcomponent) Anyone help pls?

  • @XRCADIA
    @XRCADIA 5 років тому

    New video about Addressables, asset bundles, and lastly resources plz :D

  • @sconosciutosconosciuto2196
    @sconosciutosconosciuto2196 5 років тому +1

    1:04 how to go to another script like them? (Which keys)

  • @lucasbrandao9835
    @lucasbrandao9835 5 років тому +1

    how can I identify a private object?
    for example, in the scene there is a cube, and I want to make a reference of it:
    -------------------------------------------------- ----------------------------
    private GameObject Cube;
    void Start {
    Cube = GameObject ("cube");

    • @monohybridstudios
      @monohybridstudios 5 років тому +1

      Use [SerializeField] if the object is within the scene and drag-drop gameobject to the serialized field within the editor. If the object is instantiated at run-time, you'll need to use one of the methods that the video describes above.

    • @lucasbrandao9835
      @lucasbrandao9835 5 років тому

      Thank you!

  • @maelorable
    @maelorable 4 роки тому

    Forgive me, Im new to OOP and Unity... Why are none of these classes in your examples ever being newed up. I see in most of the examples scoremanager.addscore is called, but I never see a new instance of scoremanager created in clicktokill. Am I missing something? In one instance you used a static, but in the other 4 I didnt see any static members.

  • @oystercam1040
    @oystercam1040 3 роки тому

    hi, can you plz do a video showing how to do a board game on unity, where can the character choose to go or not to the other way? like a square with a line on de midle where they walk on it based on a dice movement..it would be really amazing ;v;

  • @BinaryLynx
    @BinaryLynx 2 роки тому +1

    My left ear got a lot of information

  • @nicrap01
    @nicrap01 4 роки тому

    Why is Dan Harmon doing videos on unity?

  • @lesalabs
    @lesalabs 4 роки тому

    How can I get a reference for this?
    However you can just get it!

  • @MahmoudSalah-gk8nc
    @MahmoudSalah-gk8nc 6 років тому

    Hello I have an issue whe n I write FindObjectOfType() it's nto getting any game object in the scene means i can't refer to game object in the scene from script any solution please ?

    • @no-body-22
      @no-body-22 5 років тому

      Hello. FindObjectOfType is used for finding a script or other component and there is only one of them in the scene. To search for an object by name, use GameObject.Find("name"). For example: GameObject cube; then in Start function: cube = GameObject.Find("name");

  • @ShaulAtiya
    @ShaulAtiya 3 роки тому

    there is no pub-sub ?