CreateControlPoints() public static method

public static CreateControlPoints ( SkinnedMeshRenderer skin ) : void
skin SkinnedMeshRenderer
return void
Example #1
0
    public override void OnInspectorGUI()
    {
        Skin2D skin = (Skin2D)target;

        DrawDefaultInspector();

        EditorGUILayout.Separator();

        /* Moved to skeleton for multiple Skin2D
         * if (skin.selectedBones != null && skin.GetComponent<MeshFilter>().sharedMesh != null && GUILayout.Button("Calculate weights")) {
         * skin.CalculateBoneWeights();
         * }*/

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Save as Prefab"))
        {
            skin.SaveAsPrefab();
        }

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Recalculate Bone Weights"))
        {
            skin.RecalculateBoneWeights();
        }

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Create Control Points"))
        {
            ControlPoint.CreateControlPoints(skin.GetComponent <SkinnedMeshRenderer>());
        }

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Reset Control Points"))
        {
            skin.ResetControlPointPositions();
        }
    }
Example #2
0
    public override void OnInspectorGUI()
    {
        Skin2D skin = (Skin2D)target;

        DrawDefaultInspector();

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Save as Prefab"))
        {
            skin.SaveAsPrefab();
        }

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Recalculate Bone Weights"))
        {
            skin.RecalculateBoneWeights();
        }

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Create Control Points"))
        {
            ControlPoint.CreateControlPoints(skin.GetComponent <SkinnedMeshRenderer>());
        }

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Reset Control Points"))
        {
            skin.ResetControlPointPositions();
        }

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Generate Mesh Asset"))
        {
            #if UNITY_EDITOR
            ScriptableObjectUtility.CreateAsset(skin.GetComponent <SkinnedMeshRenderer>().sharedMesh);
                        #endif
        }

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial != null && GUILayout.Button("Generate Material Asset"))
        {
            #if UNITY_EDITOR
            Material material = new Material(skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial);
            material.CopyPropertiesFromMaterial(skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial);
            skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial = material;
            AssetDatabase.CreateAsset(material, "Assets/" + material.mainTexture.name + ".mat");
                        #endif
        }
    }
Example #3
0
    public override void OnInspectorGUI()
    {
        Skin2D skin = (Skin2D)target;

        DrawDefaultInspector();

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Save as Prefab"))
        {
            skin.SaveAsPrefab();
        }

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Recalculate Bone Weights"))
        {
            skin.RecalculateBoneWeights();
        }

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Create Control Points"))
        {
            ControlPoint.CreateControlPoints(skin.GetComponent <SkinnedMeshRenderer>());
        }

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Reset Control Points"))
        {
            skin.ResetControlPointPositions();
        }

        EditorGUILayout.Separator();

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMesh != null && GUILayout.Button("Generate Mesh Asset"))
        {
            #if UNITY_EDITOR
            // Check if the Meshes directory exists, if not, create it.
            if (!Directory.Exists("Assets/Meshes"))
            {
                AssetDatabase.CreateFolder("Assets", "Meshes");
                AssetDatabase.Refresh();
            }
            ScriptableObjectUtility.CreateAsset(skin.GetComponent <SkinnedMeshRenderer>().sharedMesh, "Meshes/" + skin.gameObject.name + ".Mesh");
                        #endif
        }

        if (skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial != null && GUILayout.Button("Generate Material Asset"))
        {
            #if UNITY_EDITOR
            Material material = new Material(skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial);
            material.CopyPropertiesFromMaterial(skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial);
            skin.GetComponent <SkinnedMeshRenderer>().sharedMaterial = material;
            if (!Directory.Exists("Assets/Materials"))
            {
                AssetDatabase.CreateFolder("Assets", "Materials");
                AssetDatabase.Refresh();
            }
            AssetDatabase.CreateAsset(material, "Assets/Materials/" + material.mainTexture.name + ".mat");
            Debug.Log("Created material " + material.mainTexture.name + " for " + skin.gameObject.name);
                        #endif
        }
    }