Hi Everyone !
I’m trying to do something simple but I am new in Unity and Script.
The aim is to disable on enable a script with a toggle button.
I want to see the outside of my object when the toggle is off and see the inside of my object when it’s on.
I can activate it but I can’t disable it.
I think this is because my script is in void Start() but I don’t know how to fix it.
If someone can help me that’s well be great !! Thanks a lot (:
using UnityEngine;
using System.Collections;
[RequireComponent(typeof(MeshFilter))]
public class ReverseNormals : MonoBehaviour {
void Start () {
MeshFilter filter = GetComponent(typeof (MeshFilter)) as MeshFilter;
if (filter != null)
{
Mesh mesh = filter.mesh;
Vector3[] normals = mesh.normals;
for (int i=0;i<normals.Length;i++)
normals _= -normals*;*_
* mesh.normals = normals;*
* for (int m=0;m<mesh.subMeshCount;m++)*
* {*
* int[] triangles = mesh.GetTriangles(m);*
* for (int i=0;i<triangles.Length;i+=3)*
* {*
* int temp = triangles[i + 0];*
* triangles[i + 0] = triangles[i + 1];*
* triangles[i + 1] = temp;*
* }*
* mesh.SetTriangles(triangles, m);*
* }*
* } *
* }*
}