UnityEditor.ClothInspector.OnEnable C# (CSharp) Method

OnEnable() private method

private OnEnable ( ) : void
return void
        private void OnEnable()
        {
            if (s_SelectionMaterial == null)
            {
                s_SelectionMaterial = EditorGUIUtility.LoadRequired("SceneView/VertexSelectionMaterial.mat") as Material;
                s_SelectionMaterialBackfaces = EditorGUIUtility.LoadRequired("SceneView/VertexSelectionBackfacesMaterial.mat") as Material;
                s_SelectedMaterial = EditorGUIUtility.LoadRequired("SceneView/VertexSelectedMaterial.mat") as Material;
            }
            if (s_ColorTexture == null)
            {
                s_ColorTexture = this.GenerateColorTexture(100);
            }
            if (s_ToolIcons == null)
            {
                s_ToolIcons = new GUIContent[] { EditorGUIUtility.TextContent("Select|Select vertices and edit their cloth coefficients in the inspector."), EditorGUIUtility.TextContent("Paint|Paint cloth coefficients on to vertices.") };
            }
            if (s_ModeStrings == null)
            {
                s_ModeStrings = new GUIContent[] { EditorGUIUtility.TextContent("Fixed"), EditorGUIUtility.TextContent("Max Distance"), EditorGUIUtility.TextContent("Surface Penetration") };
            }
            if (s_PaintIcon == null)
            {
                s_PaintIcon = EditorGUIUtility.IconContent("ClothInspector.PaintValue", "|Change this vertex coefficient value by painting in the scene view.");
            }
            this.m_VertexMesh = new Mesh();
            this.m_VertexMesh.hideFlags |= HideFlags.DontSave;
            Mesh builtinResource = (Mesh) Resources.GetBuiltinResource(typeof(Mesh), "Cube.fbx");
            this.m_VertexMesh.vertices = new Vector3[builtinResource.vertices.Length];
            this.m_VertexMesh.normals = builtinResource.normals;
            Vector4[] vectorArray = new Vector4[builtinResource.vertices.Length];
            Vector3[] vertices = builtinResource.vertices;
            for (int i = 0; i < builtinResource.vertices.Length; i++)
            {
                vectorArray[i] = (Vector4) (vertices[i] * -0.01f);
            }
            this.m_VertexMesh.tangents = vectorArray;
            this.m_VertexMesh.triangles = builtinResource.triangles;
            this.m_VertexMeshSelected = new Mesh();
            this.m_VertexMeshSelected.hideFlags |= HideFlags.DontSave;
            this.m_VertexMeshSelected.vertices = this.m_VertexMesh.vertices;
            this.m_VertexMeshSelected.normals = this.m_VertexMesh.normals;
            for (int j = 0; j < builtinResource.vertices.Length; j++)
            {
                vectorArray[j] = (Vector4) (vertices[j] * -0.02f);
            }
            this.m_VertexMeshSelected.tangents = vectorArray;
            this.m_VertexMeshSelected.triangles = this.m_VertexMesh.triangles;
            s_MaxVertices = 0x10000 / this.m_VertexMesh.vertices.Length;
            this.GenerateSelectionMesh();
            this.SetupSelectedMeshColors();
            SceneView.onPreSceneGUIDelegate = (SceneView.OnSceneFunc) Delegate.Combine(SceneView.onPreSceneGUIDelegate, new SceneView.OnSceneFunc(this.OnPreSceneGUICallback));
        }