コード例 #1
0
#pragma warning disable 612
        /// <summary>
        /// Utility to help convert objects modified with the Beta version of Polybrush (Asset Store)
        /// to Polybrus 1.x.
        /// </summary>
        /// <param name="component"></param>
        internal static PolybrushMesh ConvertGameObjectToNewFormat(z_AdditionalVertexStreams component)
        {
            GameObject    go           = component.gameObject;
            PolybrushMesh newComponent = go.GetComponent <PolybrushMesh>();
            MeshFilter    mf           = go.GetComponent <MeshFilter>();
            Mesh          mesh         = component.m_AdditionalVertexStreamMesh;

            Undo.DestroyObjectImmediate(component);

            // Cancel conversion if no mesh if found on Z_AdditionalVertexStreams
            if (mesh == null)
            {
                return(null);
            }

            if (newComponent == null)
            {
                newComponent = Undo.AddComponent <PolybrushMesh>(go);
                newComponent.Initialize();
            }

            newComponent.mode = PolybrushMesh.Mode.AdditionalVertexStream;
            newComponent.SetMesh(PolyMeshUtility.DeepCopy(mf.sharedMesh));
            newComponent.SetAdditionalVertexStreams(mesh);

            return(newComponent);
        }
コード例 #2
0
        void DrawExtraActions()
        {
            PolybrushMesh polybrushmesh = target as PolybrushMesh;
            MeshRenderer  mr            = polybrushmesh.gameObject.GetComponent <MeshRenderer>();

            using (new EditorGUILayout.HorizontalScope())
            {
                // Export button
                if (GUILayout.Button(Styles.k_ExportButtonLabel))
                {
                    PolyEditorUtility.SaveMeshAsset(polybrushmesh.polyMesh.ToUnityMesh());
                }

                // Reset button
                if (GUILayout.Button(Styles.k_DeleteButtonLabel))
                {
                    if (EditorUtility.DisplayDialog(Styles.k_DisplayDialogTitle,
                                                    Styles.k_DisplayDialogMessage, Styles.k_DisplayDialogOkLabel, Styles.k_DisplayDialogCancelLabel))
                    {
                        foreach (PolybrushMesh polybrushMesh in targets)
                        {
                            if (polybrushMesh == null)
                            {
                                continue;
                            }

                            polybrushmesh.SetMesh(polybrushmesh.sourceMesh);
                            Undo.DestroyObjectImmediate(polybrushmesh);
                        }
                    }
                }
            }
        }