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.

Using code tags properly

Discussion in 'Scripting' started by Adam-Buckner, Jul 16, 2012.

Thread Status:
Not open for further replies.
  1. APSchmidt

    APSchmidt

    Joined:
    Aug 8, 2016
    Posts:
    4,322
    Ah, okay, it's my browser's fault now. All right, I'm stupid, you are not. I guess carrying on here;is useless, you don't want to listen and the issue will never be fixed and people will keep posting code without using tags, as they do, and their scripts will be incomprehensible and they'll get little help.

    I'll never post any link to this thread from now on.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,355
    Yeah, talk about missing the point. (Which was only that formatting isn't deliberately stripped, it's still there even if it doesn't help.) Maybe if you read the entire post? There were a bunch of words after that, which contained the relevant stuff. I'm not in a position to do anything about it, so I offered some suggestions based on what appears to be a higher success rate of formatted code on UnityAnswers. But hey, just ignore all that and write a put-upon post, since that really makes everything better.

    --Eric
     
    razamgar likes this.
  3. KelsoMRK

    KelsoMRK

    Joined:
    Jul 18, 2010
    Posts:
    5,539
    That escalated quickly....
     
  4. Dave-Carlile

    Dave-Carlile

    Joined:
    Sep 16, 2012
    Posts:
    967
    I don't think anyone was really disagreeing with you, just establishing the current behavior and why it is what it is, but I guess maybe it felt like people were piling on. It would actually be awesome to have some sort of automated code detection and formatting. Is there any place that actually does that? Some sort of machine learning thing would probably be helpful there.

    I think it would be helpful to change things over to use a form of Markdown like Answers and Stack Overflow where 4 character indents are interpreted as code. The first 2 or 3 lines are often not intended like that so those are missed, but much of the rest of the code gets formatted as such. Better than nothing.
     
  5. Indie_Dev

    Indie_Dev

    Joined:
    Dec 29, 2017
    Posts:
    35
    Is there any shortcut method that will allow me to indent code when entering directly into the browser?
    I'm a bit (O_C_D * 1000) when it comes to that. I will take the time to manually "spacebar" it out, but if I could not have to hit 60 spaces every time I write a 4 line if statement, it would be quite lovely ^_^
     
  6. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I wish lol. It's also sad for me when I test write code and paste it here, only to see several lines of indentation from my VS, but the snippet here requires less :) I usually update it myself, but not always. :)
     
  7. MAYALS18

    MAYALS18

    Joined:
    Jan 10, 2018
    Posts:
    1
    Code (CSharp):
    1. // Code
     
  8. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I do not know if this "Inline code" button was always present on the forums, or if it is new. I only ever used the Insert-> code when I first began, and now I just type it..

    However, I have seen a lot of posts using it lately, and it's not very good. I think it's great that the button is not "hidden" under insert for a very common code insertion, but perhaps it could be changed to be the proper code tags, rather than those inline ones. :) Please.. lol
     
  9. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,355
    Agreed, it should be removed, or better yet changed to use CODE rather than ICODE. I can't see any purpose for ICODE. It's not even inline. If it was actually inline, it would at least make some sense.

    --Eric
     
  10. BlackPete

    BlackPete

    Joined:
    Nov 16, 2016
    Posts:
    970
    Ugh, so that's where all those weird looking code posts came from. They actually do more harm than good because some long lines would get cut off, and I'd lose critical context when trying to read the code.

    Having a more visible button rather than being buried inside Insert is a good start. Now let's change it to CODE and drop this ICODE mess.

    sigh.
     
    Last edited: Mar 8, 2018
  11. and-poulsen

    and-poulsen

    Unity Technologies

    Joined:
    Sep 30, 2016
    Posts:
    66
    Cleaned this up a bit - 'Insert Code' is now on the toolbar.
     
  12. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    It's cool that there's a message about not using the other one. lol

    edited: ... will wait a while & try the new tags.
     
    Last edited: Mar 27, 2018
  13. and-poulsen

    and-poulsen

    Unity Technologies

    Joined:
    Sep 30, 2016
    Posts:
    66
    @methos5k, probably a cache problem, can you try to clear it?
     
  14. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    I will try later, as I have to leave atm. :)

    Edit: Now gives me the popup to insert code.
     
    Last edited: Mar 28, 2018
    and-poulsen likes this.
  15. methos5k

    methos5k

    Joined:
    Aug 3, 2015
    Posts:
    8,712
    This thread is for "how to use code tags properly", and not remotely related to your post.
    Try maybe general discussion?
     
    TheMeeroslav likes this.
  16. CubicCBridger

    CubicCBridger

    Joined:
    Apr 19, 2017
    Posts:
    44
    Another thing (loosely and) tangentially related to code tags is errors. I've been noticing many posts asking for help debugging code which isn't either compiling or failing at run-time, with the error as the post title or mentioned in the body. Too many times users have had to request the OP for the original error as it was not included anywhere in the thread.
    Maybe this requires a separate sticky for how to create threads for debugging errors but I thought I would initially raise it here.
    • Step 1 - Include error
    • Step 2 - Include code with code tags
    • Step 3 - Provide context
    • Step 4 - Provide attempted solutions
     
  17. TonyLi

    TonyLi

    Joined:
    Apr 10, 2012
    Posts:
    12,367
    ^ That's a good point. With runtime errors in the Unity editor, please click on the error in the Console window, press Ctrl+C (or Command+C) to copy it to the clipboard, and then paste it into the post. This will include the stack trace, which provides valuable information.
     
  18. eneroth3

    eneroth3

    Joined:
    Oct 22, 2018
    Posts:
    63
    My feature request would be to clean up the forum UI in general, and not make this arbitrary distinction between quick reply and whatever the other kind of reply is called. Preferably even switching to Discourse which has a friendly and functional UI, where you for instance can easily see when a post was written, rather than going "nope, that's the join date... that's the number of posts... *scroll* *scroll* ... that's a signature... that's the edit date... that date there that has no label, that has to be it!". I can see if that is unlikely to happen any time soon though.
     
  19. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,355
    The post you're replying to is from 2012, when the forums used vBulletin, rather than Xenforo. The issue discussed at the time is not relevant anymore; there's only one kind of reply now.

    Anyway it seems like a rather drastic overreaction to simply moving the post date around; it's not hard-coded or anything. Most other Xenforo-based forums have it at the top.

    --Eric
     
    eneroth3 likes this.
  20. justdevything

    justdevything

    Joined:
    Jul 7, 2019
    Posts:
    4
    Sometimes clearing caches in options or even using private mode doesnt work for some reason... So to be 100% sure one can always temporarily try different browser (chrome and firefox are most reputable).

    PS the code feature is amazing, on most forums and websites code block has just gray background and different font but here it highlights certain words like in IDE! Nice :)
     
  21. Alvarezmd90

    Alvarezmd90

    Joined:
    Jul 21, 2016
    Posts:
    149
    I'm having issues with spacing and tabs more than once. It's annoying. Anyone know how to avoid such problems?
     
  22. olejuer

    olejuer

    Joined:
    Dec 1, 2014
    Posts:
    205
    Agreed. I usually edit code in my IDE and copy paste it over. That usually works quite fine and is more comfortable, anyway.
     
    Alvarezmd90 likes this.
  23. Hobby-Game-Developer

    Hobby-Game-Developer

    Joined:
    Aug 27, 2017
    Posts:
    10
    Code (CSharp):
    1. Thx, but what happens, when I use code tags, for ordinary comments? Oh, that's what happens.... Nice. I will use Code tag in the future! I use them for everything!
     
  24. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,554
    Is there any chance a mod can update the OP of this thread so that it matches the new forum interface? The first post presents an outdated interface that doesn't include the quick code button we have now.
     
    tjbarrott and Epsilon_Delta like this.
  25. yokoaiii

    yokoaiii

    Joined:
    Dec 21, 2020
    Posts:
    2
    how do I embed code in learn.unity comments like this one?
    upload_2020-12-28_19-51-43.png
     
  26. loganha30

    loganha30

    Joined:
    Jan 24, 2021
    Posts:
    1
    Code (CSharp):
    1.    private void Update() {
    2.          Rigidbody rb = GetComponent<Rigidbody>();
    3.          if (Input.GetKey(KeyCode.A))
    4.              rb.AddForce(Vector3.left);
    5.          if (Input.GetKey(KeyCode.D))
    6.              rb.AddForce(Vector3.right);
    7.          if (Input.GetKey(KeyCode.W))
    8.              rb.AddForce(Vector3.up);
    9.          if (Input.GetKey(KeyCode.S))
    10.              rb.AddForce(Vector3.down);
     
  27. Callum_Coombs

    Callum_Coombs

    Joined:
    Feb 26, 2019
    Posts:
    10
    Thanks for the information! Excellent Post!
     
  28. Epsilon_Delta

    Epsilon_Delta

    Joined:
    Mar 14, 2018
    Posts:
    185
    Bump this. So many forum threads/posts without proper use of codetags are linked here to show people how the codetags should be used. And when they come here, they see obsolete interface, which can add to their confusion.
     
    _geo__, tjbarrott and PraetorBlue like this.
  29. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,063
    Updated
     
    MaskedMouse and PraetorBlue like this.
Thread Status:
Not open for further replies.