Question by
derricka59 · Apr 13, 2018 at 11:27 PM ·
error messagenewbieformatting
I'm very new to coding and was wondering if anyone could help me with leaving clean code pasting when I have a question also new to unity and this site as well
so Im not really sure how to use this site im not used to dealing with a editor that outputs soomething other than whats written as far as formatting goes so any help would be great
Comment
Read and do searches. "Unity Answers paste code" will give several answered Q's from here, with more information.
Best Answer
Answer by MarioSantoso · Apr 14, 2018 at 02:44 AM
When you want to post a code, use the Code Sample feature (it's the button with 101010 image)
The code you paste should look like this
using UnityEngine;
public class Test : MonoBehaviour
{
private void Start()
{
Debug.Log(DoIHaveMeshRenderer(transform));
}
public bool DoIHaveMeshRenderer(Transform objectToBeChecked)
{
bool _descendantHasMeshRenderer = false;
if (objectToBeChecked.childCount > 0)
for (int i = 0; i < objectToBeChecked.childCount; i++)
_descendantHasMeshRenderer = DoIHaveMeshRenderer(objectToBeChecked.GetChild(i));
if (_descendantHasMeshRenderer)
return true;
if (objectToBeChecked.GetComponent<MeshRenderer>() != null)
return true;
else
return false;
}
}
@ $$anonymous$$ilsnus Thank you very much That will be very useful. $$anonymous$$y code samples were looking pretty bad