Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Add Properties to a GameObject

Discussion in 'Scripting' started by ThySpektre, Jul 22, 2019.

  1. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,903
    Code (CSharp):
    1. public class Duck : MonoBehavior, IResettable
    2. {
    3.     public void Reset()
    4.     {
    5.         GameObject go = this.gameObject;
    6.         // The exact same logic as above using go instead
    7.      }
    8. }
    Edit: and you just beat me to the #100 post in this generally dumb thread. :D
     
  2. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    The inheritance method expressly does not have the same problem. Each new object can implement its own Reset functionality.
     
  3. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Why would language be "inflammatory" if someone was not emotional about the issue?
     
  4. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    ...by extending ResettableGameObject, which you is exactly what you can do with a component if you want. They are identical.
    Look at this
    Code (csharp):
    1. public class Door : ResettableGameObject
    2. {
    3.     public override void Reset() { /* custom door logic */ }
    4. }
    Can you tell if ResettableGameObject is a component or a fictional extension of GameObject? You shouldn't do this, and should use interfaces instead, but there's nothing stopping you from making a 1 to 1 map from a GameObject inheritance hierarchy to a MonoBehaviour hierarchy.
     
  5. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    Because language is the mechanism by which humans transmit ideas to one another. Some elements of language convey emotion, since emotion is itself an idea. For example "kludge" is itself an emotional word that communicates the emotion of the person using it. The official definition of "kludge" is this: an ill-assorted collection of parts assembled to fulfill a particular purpose. Note "ill-assorted". By saying "kludge", you imply that the method is improper, which is incorrect. When people hear incorrect information, they have an emotional response: dislike. This is likely a result of evolutionary pressures, since operating on incorrect information could be fatal in evolutionary contexts.
     
  6. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Even given your definition, kludge is not an emotional word. Would stating using a wrench for a nail is a kludge be emotive? It is not the word which is emotional.

    The definition of kludge you state is correct, but commenting on its applicability or not is a judgement for the user of the language. It is most definitely a kludge to use Interfaces to implement inheritance. You may decide that in your instance inheritance is not an important feature and thus there is no need for inheritance. Such does not make the statement incorrect. Perhaps if one feels some sort of tribal allegiance to one camp or another, hearing someone comment on the applicability of a method to a task would form an emotional response, but such is certainly not the property of the language used, but rather the allegiance held.

    In short, take responsibility for you own actions. They are not the direct result of someone else.
     
    Last edited: Jul 26, 2019
  7. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    I understand what you are saying. So let me ask you. Do you find this hierarchy of behaviors that must all make calls through the GameObject to which they are attached in order to interact as clean or efficient a structure as an object that implements it's own methods?
     
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,124
    Just about every reply has been reasonable. It's just that you're not reasonable. If you wanted a community where everyone agreed with every nonsensical statement you made you're in the wrong place. So to summarize, not only did you choose the wrong engine, you choose the wrong forum too.

    Your first sentence was the answer. They're not a sane developer any more than they are a reasonable one. :p
     
    Suddoha and Lurking-Ninja like this.
  9. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    Yes it is. Saying something is ill-assorted is emotive. Although we may agree that wrenches are not good tools for driving nails, we do so emotionally. You did not reason yourself to that position.

    Thus making it emotive.

    Then don't use it to implement inheritance. Use it to implement composition.

    This doesn't make logical sense. I didn't claim that the many problems with inheritance make your claim incorrect. I claimed that labeling interfaces and composition a "kludge" is incorrect because they are used in the standard libraries of Java and C#.

    This is a non-sequitur and a strawman in one. I will fully admit to having a tribal allegiance to the truth though, which informs my objection to your claims. For example, claiming that emotion is not a property of language is absurd.

    Define "direct". Provocation is recognized as a concept throughout the entire world, so if you are claiming it is not possible to provoke someone else to action through language alone, I don't know what to tell you.
     
    Lurking-Ninja likes this.
  10. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    You personally decide a wrench is not a good tool to drive in a nail emotionally? While I can't speak to your experience, I think a good number of people come to that conclusion through logic and reason.

    If indeed you come by your decision making processes through emotion as you describe here, then indeed most any statement is "emotive".

    Now, do you come by your decisions based upon "truth" or do you come by your decisions based upon "emotion"? You seem quite conflicted on this issue. On the one hand you decide which tool is proper for the job based on emotion, on the other hand you come by them based on your "tribal allegiance to the truth".

    Webster's will do:

    1a: proceeding from one point to another in time or space without deviation or interruption : STRAIGHT a direct line
    b: proceeding by the shortest way
    //the direct route
    2a: stemming immediately from a source
    //direct result
    b: being or passing in a straight line of descent from parent to offspring : LINEAL
    //direct ancestor
    c: having no compromising or impairing element
    //a direct insult

    {/quote]

    Now, if my words do indeed directly causes your reactions without any intervening reasoning processes you might employ, then yes, I guess I would be directly responsible for your reactions and emotions. Thus my emploring you to own them yourseld.

    It is not possible to provoke someone through language alone. Not if we accept the concept of the individual. Own your actions.
     
  11. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    I'm not looking for a community where everyone agrees. I would however think a community that only offers responses to the questions poised, as opposed to imagined questions, and limits responses to those would be more efficient.
     
  12. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Upon further reflection, I think this confirms what I had stated a good while back in the thread. The choice of tool being suggested here has been come to by some emotionally. For others in this same boat, I wish you well, but I'm looking for a reasoned approach to accomplish the task called for in the first post.
     
  13. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    That being said, this thread has bordered on disrespectful on a number of occasions. For any component of that that was directly caused by me, I apologize. I likely won't check in for additional replies on the thread. If a future reader stumbles on the thread and had a better kludge than the manager class discussed here, feel free to PM me. I'd love to hear about your insights.
     
  14. WallaceT_MFM

    WallaceT_MFM

    Joined:
    Sep 25, 2017
    Posts:
    394
    That is a delusion that has been proven false since the early days of psychology. Almost every conclusion a person makes is emotional, as you point out.
    This is a false dichotomy, because truth isn't a method. Truth is a property of a statement or fact (ignoring epistemology, since that subject is too large for consideration here). Every person attempts to determine the truth of situation primarily through emotion, and only very slightly through reason. If you would like a reference to the psychological literature on this subject, I'll put one together for you.

    It doesn't matter if there are intervening reasoning processes or not. That isn't how direct responsibility is determined. Yes, it is true that you are not physically adjusting the chemicals in my brain. That is irrelevant. I am responsible for the actions I take, not the emotions I feel as a response to external stimulii.

    This makes no sense whatsoever. I accept the concept of the individual. What of it? Are you talking about classic formulations of individualism? Are we having a political debate now? I am provoke you to action at this very moment with language alone, as can be seen by you responding.
    The great irony of you telling other people to own their actions is very amusing, though. You steadfastly refuse to accept your own responsibility for provoking other people. Do you see anyone else getting the same treatment as you? Do you think this is some conspiracy? Whenever someone interacts with you, the exchange is negative. I wonder what the common factor is.
     
  15. Baste

    Baste

    Joined:
    Jan 24, 2013
    Posts:
    6,194
    Why is everybody feeding this troll?
     
    Xarbrough, Boz0r, Ryiah and 1 other person like this.
  16. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Are you trying to get me to implement this easy thing for you?
    I think you just didn't read the TODO comments.

    Neither, nor.

    You only have one of those components / GO. It's a 1:1 relation. Just like you would have the GO directly.
    With that you do not need a list of multiple components.

    And how can a type agnostic data blob, no matter how it is built, be an indicator for OOP, when its whole purpose is to be object and type-agnostic? Absolute non-sense. You're coming with your own defintions that don't even make sense.

    It does solve the problem with all requirements you put. I'm sorry to say that, but its true.

    If it does not:
    1) Your oiriginal idea of subclassing GO would not have worked
    2) your ability to describe your problem needs some serious improvements.

    The funny thing is I know that it works. I implemented a whole networking system about 3 years ago for a project. It synced GOs without a clue how they're composed.

    The part you're struggling with was one of the easier parts.

    I've now digged a little through your post and thread history, and this explained it all to me...
     
    Last edited: Jul 27, 2019
  17. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    That's a good question. I don't even know why i keep replying... I hoped he was serious about learning something new, but apparently he's just trying to trick us into implementing this easy thing.
     
    Last edited: Jul 27, 2019
    Lurking-Ninja and Ryiah like this.
  18. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    That would probably be good advice to anyone hoping to provide help in a forum.

    Then you do not supply data to them.
     
    Last edited: Jul 26, 2019
  19. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    If you say so... i know that it does. And it passes data per GO, not per N compenents on a GO.
    Requirements met. Case closed.

    This can be implemented in less than a day, because your requirements are neither complex nor special.

    Everyone in this thread can do that, even CS 101 students can do it. Apparently it's just you who cannot.
     
    Ryiah likes this.
  20. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,124
    Once again you chose the wrong community. Getting answers with little to no discussions to them requires choosing a community where this is expected like Stack Exchange, Stack Overflow, Unity Answers, etc. Our community is as much about discussions surrounding the question as anything else.
     
    Suddoha likes this.
  21. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    I fly to Seattle and finally get on my tablet to find this fun little read. I guess suDdoha and I ride in the same boat of getting led around by this troll. Good times, lol.
     
    Suddoha likes this.
  22. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Oh I see.

    In that case, I think the Cowboys have a great chance at taking the NFC East this year.
     
  23. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Awesome. Please add a property to a GameObject and not it's component. Let me know when finished.
     
  24. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    I have a big heart, patience and lots of tolerance for everyone, including trolls and people who unconsciously or consciously refuse / resist to look beyond the borders of what they've learned. What about you? :D

    "Feed the trolls, they're starving." :p

    If you're trying to be smart or to nitpick, at least try to do it properly. Nowhere was mentioned that the proposed solution does it.

    Since your original idea was subclassing GameObject, which cannot be accomplished in a normal version of the engine, you asked for close alternatives. Those have been mentioned.
    If you insist on finding a solution that allows subclassing of GameObject, purchase a source code license or play around with Mono Cecil and dll injection. The latter is the worst you could do though, from a legal and technical point of view.

    Anyway, I don't mind if you lose all your credibility as a C# & Unity developer as your self-invented rules and defintions invalidate well-known programming paradigms, language specifications, well-known design patterns, common best practices from a whole industry so on and so forth.

    If you cannot see the obvious, we can't help it anymore. Either you're stuck with your own narrow and half-incorrect interpretation of OPP and how everything is a "klutch", or you're seriously just trolling, in which case I hopefully did my best to make you feel better.
     
    Last edited: Jul 28, 2019
    lordofduct likes this.
  25. Boz0r

    Boz0r

    Joined:
    Feb 27, 2014
    Posts:
    419
    Two months ago the dude didn't know what an interface is, and probably not composition either, so I don't know if that phrase is the only part of the OOP course he heard.
     
    Lurking-Ninja likes this.
  26. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    [
    It was in the title...

    Except most, save the manager idea I mentioned, did not accomplish what was asked. One might say a first year OOP programmer would see that, but that would be impolite.
    .

    The term was "kludge". If you instead were implementing "klutches" for some "OPP" that fits with the general theme of the responses in the thread,
     
  27. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    How is
    a response to
    ?
    I'm confused. I was talking about my proposed solution and you say it's mentioned in the title?!

    We've all realized you initially wanted to extend GameObject directly:
    And the very first reply had already supplied the answer:
    in other words: you cannot, you have to use components (or some mapping).

    Thus, your observation:
    is just the obvious and also very intuitive, logical consequence. It's an implication of the given fact that you cannot inherit GameObject.

    (Or just: What? You don't say!)

    Which bring us back to
    _____
    Edit: Nice catch with the "klutch vs kludge". New word that I had memorized incorrectly. Big apologies from a non-native speaker, but that still doesn't make your arguments about the topic's technical part any better.
     
    Last edited: Jul 28, 2019
  28. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Of the various posters in the thread, you have done a yoeman's job of trying to be helpful with the problem at hand. It is disappointing that I was unable to convey why the solutions you proposed were not the solution I was seeking. It was also disappointing that your posts devolved over time into name calling. As mentioned in several instances, I thank you for your time.
     
  29. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    I'm sorry for anything that might have been offensive to you, which clearly wasn't my intention. I admit that some words or statements can be misunderstood, and that they seem a little harsh. For my defense though, they're all pretty neutral in their appropriate context. They're neither emotively driven, nor supposed to be name calling.

    Remember that we've been running in circles for over 100 posts. And that there were already answers to your initial request among the earliest posts, stating it cannot be done that way.

    So we agreed to find alternatives.

    You refused to accept working alternatives for some reasons nobody really understands. Plenty developers cannot follow your reasoning, however, they can follow along when others post a solution and they agree.
    Saying you still haven't seen a good alternative leads to the impressions that the problem is at your end. Whatever this may be. Perhaps it's a just a missing detail, perhaps your description is not as clear as you think. Perhaps these concepts are so unfamiliar to you that you just cannot get out of an old habit or your comfort zone, which seems to be heavily built around that one single tool called inheritance.

    This is an impression that's based on what you've posted. This is no offense at all. It's an observation as you refuse to take a road that does not follow the idea of inheriting GameObject.

    We don't know what keeps you there.

    The probability that plenty of experienced developers are just not capable of finding a good alternative to that simple problem is rather low... close to zero. I mean, they've been posted. They exist.

    Anyway, good luck. In all honesty. No sarcasm.
     
    Last edited: Jul 29, 2019
    bobisgod234, lordofduct and Ryiah like this.
  30. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,124
    This. It's completely reasonable to ask for a second opinion when a doctor tells you that you need surgery because it's always possible that one doctor got it wrong, but it's far less reasonable when you visit every doctor in your area and they all say that you need it.

    Getting multiple opinions on a programming task isn't just completely reasonable it's practically guaranteed with just about every form of community. That said the reasonableness of it rapidly deteriorates once you reach the point that the majority of the responders are agreeing with the same solution.

    Getting multiple opinions that don't align at all is a sign the discussion should continue, but getting multiple opinions that do align is a sign that the problem is solved, and if you can't accept that then I'm sorry but that's on you and your limits as a developer not us.
     
    Suddoha and lordofduct like this.
  31. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    I make no representation that the insults were emotively driven. Perhaps you just insult as a matter of course. I have not refused any working alternative. None of them have accomplished what was desired.

    They all so far have has the feeling of that old joke upon where someone see a man down on all fours searching about. He asks the man what he's doing and the man replies "Looking for my watch". "Where did you lose it?" The man replies, "Up the street about a block."

    "Then why are you looking here?"

    "The light's much better here."

    No matter how much you might search here, the watch (solution) is up the street from what's been presented.
     
  32. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Argumentum ad populum.
     
  33. Lurking-Ninja

    Lurking-Ninja

    Joined:
    Jan 20, 2015
    Posts:
    9,903
    This is pretty much it. Learn how to use a hammer: everything seems to be a nail until you learn how to use a screwdriver.
     
    Ryiah and Suddoha like this.
  34. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    What you desired is not possible. Change the engine's source code, then it's possible.

    You did not accept that fact. If you did, you'd either agree that an alternative is needed in order to make any progress. And if an alternative is required, it'll be one of those that have been posted.

    That's a matter of simple logic.

    As for the so called insults, that's your subjective interpretation, just like I have my own subjective view on it. I posted it, I know that nothing was meant to be anything close to insults. There's no reason to insult anyone here.
    And the fact that there's no explicit name calling invalidates your claims, or lets say your assumptions.

    If you post incorrect definitions and anything like that over and over again, anyone is free to say that there's either a misunderstanding of concepts, there's a knowledge gap, or that you're just trying to led us around, like Lord said it.
    In no way that's an insult. Multiple options, one of it holds true. Whatever the result is, it's also a fact.

    For example, comparisons were added in order to put some emphasis on a given fact, more specifically, on the simplicity of implementing an alternative. It is not an insult either.
     
    lordofduct and Ryiah like this.
  35. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,124
    This. You wouldn't be able to implement what was desired even if the class wasn't sealed because a GameObject is not just a C# class in Unity. There is core functionality implemented in C++ that cannot be modified or overridden without accessing the source code of the engine.

    Extending MonoBehaviour would be the closest workaround. A custom one that searches for the most relevant manager object, presents it with the list of fields that need to be serialized, registers events for sending and receiving the values of them, etc. I don't remember if this was presented already as this thread is too full of the OP's nonsense.
     
    Last edited: Jul 30, 2019
  36. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Calling one a troll is not normally a term of endearment.
     
  37. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Logical fallacy. There ARE nails.
     
  38. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,124
    You've done nothing that would make us want to be endeared towards you. Every response you've provided is either a statement brushing off our assistance, or straightup trolling responses. If anything your responses are making us never want to assist you again. Which isn't a good thing when you're doing it to some of the most helpful people available.
     
    Last edited: Jul 30, 2019
    lordofduct and Suddoha like this.
  39. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    I agree, consider though:

    That's just one of the options available, even though it's still not very likely IMO (I still believe in you for some reason I cannot explain).

    If you were a troll, I could call you a troll.
    If it is a fact, I can speak it out loud.

    Anything else you'd like to argue about?
     
    Last edited: Jul 30, 2019
  40. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    That someone possess a trait, does not mean calling it out is not an insult.

    "Man...you'e fat."

    I'm not saying I am a troll, just stating it would not absolve you of the insult either way. A statement need not be false to be insulting.
     
  41. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Would the proposals of future help, be as helpful and fun filled as this incident has been?
     
  42. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,124
    It's completely up to you. Every response here was written the way it is because of the way you responded.
     
  43. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    I'm sorry you all are automatons.
     
  44. lordofduct

    lordofduct

    Joined:
    Oct 3, 2011
    Posts:
    8,380
    I love your criticism of us insulting you because you attach emotional meaning to terms like "troll" of your own accord.

    You know... similar to words like kludge and automatons.

    An internet troll is just someone who posts inflamatory remarks on the internet which gets a reaction from the community. That's just fact. If you're offended by that... well, that's on you.
     
    Ryiah likes this.
  45. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Nothing I posted was inflammatory unless you were emotionally invested in the topic before responding. As for automaton, I wasn't the one claiming someone else controlled what I posted.

    You also claim I attached an emotional meaning to the term "troll". This is incorrect. I claimed it was an insult.
     
  46. Boz0r

    Boz0r

    Joined:
    Feb 27, 2014
    Posts:
    419
    Everything in Unity is pre-drilled and ready for screws, like IKEA furniture. Of course you could hammer some nails into it, but that doesn't make anything easier.
     
  47. Suddoha

    Suddoha

    Joined:
    Nov 9, 2013
    Posts:
    2,824
    Easy. Weak argument. :) I expected that answer.

    Compare the intents of a troll:
    (Source: https://en.m.wikipedia.org/wiki/Troll)

    with an overweight person.

    What would an overweight person do, with its weight specifically, that'd offend and entitle you to call him or her "fat"?

    Still waiting to go back to the original topic.

    Let's start:

    If this is impossible:
    Manager -> GoSubclass [Blackbox]

    Why don't you:
    Manager -> GoProxy [Blackbox & access to GameObject]

    Tell us why you don't accept it. You still haven't done it up to this point.

    Before you reply: please, let's skip this part of the conversation:

    You: "I want to add properties to a GO, not to a component."
    XYZ: "You cannot. You have to use another type, e.g. a component."
    You: "That's a kludge. I want to add properties to a Go, not to a component"
    XYZ: "You still cannot do that."
    You: "But I want to ...."

    Option 1: Accept alternatives. Continue.
    Option 2: Refuse alternatives. Stop here.
     
    Last edited: Jul 31, 2019
    Ryiah likes this.
  48. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    20,124
    The statement "You are all automatons" is very clearly intended to be provocative which is the definition of "inflammatory".

    upload_2019-7-31_10-43-5.png

    And this is by no means the only post in this thread by you that has been an attempt to provoke a response from us. In fact just about every post that isn't you whinging about how you want exactly the code you requested likely fits this definition.
     
    lordofduct likes this.
  49. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    If it is such a simple argument, to defeat, why did you proffer it in the first place?

    Perhaps you have missed the multiple posts where I have stated this is the manager class kludge I have implemented. I was hoping for other kludges that would work around the Unity limitation that didn't requiring keeping lists of attached components, and worked agnostically.
     
  50. ThySpektre

    ThySpektre

    Joined:
    Mar 15, 2016
    Posts:
    362
    Some folks are content with IKEA furniture. Some realize there is better furniture available and modify their IKEA furniture to resemble it.

    Yet other people point to milk crates and say "look...furniture"