Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
  • Moderators /
avatar image
0
Question by hexagonius · Jan 24, 2016 at 12:24 PM · formatting

Code sample misses using directives and class name

I was wondering why users did not format their code blocks right and just came across the same issue. Maybe someone can explain it to me or fix it, I don't know how I made it happen, but it's a little annoying because It's happening to users all the time. It always looks like this using UnityEngine; using System.Collections; using UnityEngine.UI; public class Dotafter3 : MonoBehaviour { Text text;

     // Use this for initialization
     void Start () {
         text = GetComponent<Text> ();
 ...
Comment
Add comment · Show 3
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Immanuel-Scholz · Apr 15, 2016 at 12:32 PM 0
Share

Would it be interesting to file a request to the Unity ad$$anonymous$$s for a plugin that scans new paragraphs for "using UnityEngine;" and indents the "whole paragraph including the next indented text"?

This is a site about Unity source code after all and this particular problem case could be automated..

Just saying..

avatar image Owen-Reynolds Immanuel-Scholz · Apr 15, 2016 at 01:22 PM 0
Share

Probably not. People should be posting small, relevant code sections -- ideally from the test code they made to try to isolate the issue. Almost every Q with a using line doesn't belong here. At best, in the Help Room as an "I'm completely lost" Q. In those cases, the messed-up paragraph helps readers see that.

It's also difficult to get changes to the code running the site -- there are several technical fixes which have been on the to-do list for some time.

avatar image Immanuel-Scholz Owen-Reynolds · Apr 15, 2016 at 01:28 PM 0
Share

Yea, you are right.

Although I dream of a feature where you still can post the whole file and then mark a specifc part (or multiple parts) to be shown as "this is relevant". When the reader whishes, he still can expand the code to see more context.

Or at least specify the starting line number of a code snippet to make it match error lines. I am sometimes tempted to just dump whole files to not have to adjust stack trace line numbers or do some cumbersome description "this points to the third line, no wait the fifth and then I removed two lines so the next error is the seventh line blabla.."

3 Replies

· Add your reply
  • Sort: 
avatar image
2

Answer by Dave-Carlile · Jan 24, 2016 at 04:19 PM

The code has to be indented 4 spaces to get formatted. You can do this easily by first making sure the first line of code starts on its own line, then select all of the code and press the 101010 button which will do the indentation for you.

The reason you see some code partially formatted is that some of it ends up indented 4 spaces because of the natural indentation that's part of the code.

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hexagonius · Jan 25, 2016 at 09:01 PM 0
Share

I was using the pop-up for the code formatting, which means the 4 spaces are not added automatically I guess. Thanks for the explanation.

avatar image
1

Answer by Owen-Reynolds · Jan 24, 2016 at 04:38 PM

I think it's someone who pasted their entire file with no attempt at formatting.

4 or more spaces at the start of a line will format it as code. So for the first pasted line indented that far, code-formatting accidentally kicks in. I've never looked, but I suppose the final close-curly brace might also be plain-text.

I also always figured that someone pasting an entire script is just overwhelmed in general. The answer to most of those Q's is something completely unrelated -- like putting the script on the player.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image
0

Answer by meat5000 · Feb 10, 2016 at 07:01 PM

People break their formatting when they do it the 'correct way'. This is pressing the code button and dumping your code in it.

Its Broken.

Do it the other way. Highlight and then press the code button.

Comment
Add comment · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

37 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Doubled question and details 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges