Esempio n. 1
0
    public DFTubeData Get()
    {
        DFTubeData newObj = new DFTubeData();

        newObj.name                    = this.name;
        newObj.makeSurface             = this.makeSurface;
        newObj.divisionY               = this.divisionY;
        newObj.divisionR               = this.divisionR;
        newObj.sizeY                   = this.sizeY;
        newObj.sizeR                   = this.sizeR;
        newObj.thickness               = this.thickness;
        newObj.angle                   = this.angle;
        newObj.curveField              = AnimationCurve.Linear(0.0f, 1.0f, 1.0f, 1.0f);
        newObj.curveField.keys         = (Keyframe[])this.curveField.keys.Clone();
        newObj.curveField.preWrapMode  = this.curveField.preWrapMode;
        newObj.curveField.postWrapMode = this.curveField.postWrapMode;
        newObj.isReverse               = this.isReverse;
        newObj.isMirror                = this.isMirror;
        newObj.bendDegree              = this.bendDegree;
        newObj.bendDirection           = this.bendDirection;
        newObj.shift                   = this.shift;
        newObj.shiftDirection          = this.shiftDirection;

        return(newObj);
    }
Esempio n. 2
0
    public DFTubeData Get()
    {
        DFTubeData newObj = new DFTubeData();
        newObj.name = this.name;
        newObj.makeSurface = this.makeSurface;
        newObj.divisionY = this.divisionY;
        newObj.divisionR = this.divisionR;
        newObj.sizeY = this.sizeY;
        newObj.sizeR = this.sizeR;
        newObj.thickness = this.thickness;
        newObj.angle = this.angle;
        newObj.curveField = AnimationCurve.Linear(0.0f, 1.0f, 1.0f, 1.0f);
        newObj.curveField.keys = (Keyframe[])this.curveField.keys.Clone();
        newObj.curveField.preWrapMode = this.curveField.preWrapMode;
        newObj.curveField.postWrapMode = this.curveField.postWrapMode;
        newObj.isReverse = this.isReverse;
        newObj.isMirror = this.isMirror;
        newObj.bendDegree = this.bendDegree;
        newObj.bendDirection = this.bendDirection;
        newObj.shift = this.shift;
        newObj.shiftDirection = this.shiftDirection;

        return newObj;
    }
Esempio n. 3
0
    void SetPresetShapeData()
    {
        tubeDataList.tubeDatas.Clear();
        DFTubeData tubeData;

        tubeData      = new DFTubeData();
        tubeData.name = "Tube";
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData       = new DFTubeData();
        tubeData.name  = "Half Tube";
        tubeData.angle = 180.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData           = new DFTubeData();
        tubeData.name      = "Cylinder";
        tubeData.thickness = 100.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData            = new DFTubeData();
        tubeData.name       = "Cone";
        tubeData.thickness  = 100.0f;
        tubeData.curveField = AnimationCurve.Linear(0.0f, 0.0f, 1.0f, 1.0f);
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData            = new DFTubeData();
        tubeData.name       = "Rugby Ball";
        tubeData.thickness  = 100.0f;
        tubeData.curveField = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f);
        Keyframe key = tubeData.curveField[0];

        key.inTangent  = 2.0f;
        key.outTangent = 2.0f;
        tubeData.curveField.MoveKey(0, key);
        tubeData.isReverse = true;
        tubeData.isMirror  = true;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData                = new DFTubeData();
        tubeData.name           = "Bowl";
        tubeData.sizeY          = 0.0f;
        tubeData.thickness      = 10.0f;
        tubeData.angle          = 180.0f;
        tubeData.bendDegree     = 180.0f;
        tubeData.bendDirection  = 90.0f;
        tubeData.shiftDirection = 180.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData            = new DFTubeData();
        tubeData.name       = "Donut";
        tubeData.sizeY      = 4.0f;
        tubeData.sizeR      = 0.2f;
        tubeData.thickness  = 100.0f;
        tubeData.bendDegree = 360;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData            = new DFTubeData();
        tubeData.name       = "Screw";
        tubeData.divisionY  = 40;
        tubeData.sizeY      = 10.0f;
        tubeData.sizeR      = 0.2f;
        tubeData.thickness  = 100.0f;
        tubeData.bendDegree = 360.0f * 3;
        tubeData.shift      = 1000.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData            = new DFTubeData();
        tubeData.name       = "Pyramid";
        tubeData.divisionY  = 40;
        tubeData.divisionR  = 4;
        tubeData.sizeY      = 1.0f;
        tubeData.sizeR      = 1.0f;
        tubeData.thickness  = 100.0f;
        tubeData.curveField = AnimationCurve.Linear(0.0f, 0.0f, 1.0f, 1.0f);
        tubeDataList.tubeDatas.Add(tubeData);
    }
Esempio n. 4
0
    void OnGUI()
    {
        if (EditorApplication.isPlayingOrWillChangePlaymode)
        {
            if (!tubeCreatorStatus.isPlaying)
            {
                tubeCreatorStatus.isPlaying = true;
                DestroyPreviewObj();
                tubeCreatorStatus.isPreview   = false;
                tubeCreatorStatus.isEditStart = false;
            }
        }
        else if (tubeCreatorStatus.isPlaying)
        {
            tubeCreatorStatus.isPlaying = false;
            if (!EditorApplication.isPlaying)
            {
                tubeCreatorStatus.isPlaying = false;
            }
            tubeCreatorStatus.isPreview   = true;
            tubeCreatorStatus.isEditStart = true;
        }

        EditorGUILayout.Space();

        EditorGUI.BeginDisabledGroup(tubeCreatorStatus.isPlaying == true);

        if (tubeCreatorStatus.shapeNames == null)
        {
            SetPresetShapeData();
            MakeShapeNameList();
        }
        tubeCreatorStatus.shape = EditorGUILayout.Popup("Preset Shape", tubeCreatorStatus.shape, tubeCreatorStatus.shapeNames);

        bool shapeChanged = (tubeCreatorStatus.shape != tubeCreatorStatus.shapeBak);

        tubeData.makeSurface = EditorGUILayout.MaskField("Surface", tubeData.makeSurface, new string[] { "Outside", "Inside", "Side End 1", "Side End 2", "Top End", "Bottom End" });

        if ((!EditorApplication.isPlaying) && shapeChanged)
        {
            tubeData.Reset();
            DestroyPreviewObj();

            if (tubeDataList.tubeDatas.Count > tubeCreatorStatus.shape)
            {
                tubeData = tubeDataList.tubeDatas[tubeCreatorStatus.shape].Get();
            }
        }

        tubeCreatorStatus.foldoutDivision = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutDivision, "Division");
        if (tubeCreatorStatus.foldoutDivision)
        {
            tubeData.divisionY = EditorGUILayout.IntSlider(INDENT + "Height", tubeData.divisionY, 1, 40);

            tubeData.divisionR = EditorGUILayout.IntSlider(INDENT + "Side", tubeData.divisionR, 1, 40);
        }

        tubeCreatorStatus.foldoutSize = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutSize, "Basic Size");
        if (tubeCreatorStatus.foldoutSize)
        {
            tubeData.sizeY = EditorGUILayout.FloatField(INDENT + "Height", tubeData.sizeY);
            if (tubeData.sizeY < MIN_SIZE)
            {
                tubeData.sizeY = MIN_SIZE;
            }

            tubeData.sizeR = EditorGUILayout.FloatField(INDENT + "Radius", tubeData.sizeR);
            if (tubeData.sizeR < MIN_SIZE)
            {
                tubeData.sizeR = MIN_SIZE;
            }

            float thicknessT = EditorGUILayout.Slider(INDENT + "Thickness (%)", tubeData.thickness, 0.0f, 100.0f);
            thicknessT         = StepLength(thicknessT);
            tubeData.thickness = thicknessT;
            thicknessRate      = thicknessT / 100.0f;

            float angleT = EditorGUILayout.Slider(INDENT + "Angle", tubeData.angle, 0.0f, 360.0f);
            angleT         = stepAngle(angleT);
            tubeData.angle = angleT;
            is360          = (tubeData.angle == 360.0f)?true:false;
        }

        tubeCreatorStatus.foldoutCurve = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutCurve, "Side Shape");
        if (tubeCreatorStatus.foldoutCurve)
        {
            tubeData.curveField = EditorGUILayout.CurveField(INDENT + "Curve", tubeData.curveField, Color.green, new Rect(0.0f, 0.0f, 1.0f, 1.0f));

            tubeData.isReverse = EditorGUILayout.Toggle(INDENT + "Reverse", tubeData.isReverse);

            tubeData.isMirror = EditorGUILayout.Toggle(INDENT + "Mirror", tubeData.isMirror);
        }

        tubeCreatorStatus.foldoutBend = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutBend, "Bend");
        if (tubeCreatorStatus.foldoutBend)
        {
            float bendDegreeT = EditorGUILayout.Slider(INDENT + "Angle", tubeData.bendDegree, 0.0f, 360.0f * 3);
            bendDegreeT         = stepAngle(bendDegreeT);
            tubeData.bendDegree = bendDegreeT;
            bendRad             = tubeData.bendDegree * Mathf.Deg2Rad;

            float bendDirectionT = EditorGUILayout.Slider(INDENT + "Direction", tubeData.bendDirection, 0.0f, 360.0f);
            bendDirectionT         = stepAngle(bendDirectionT);
            tubeData.bendDirection = bendDirectionT;
            bendDirectionRad       = Mathf.Deg2Rad * tubeData.bendDirection;
            sinBendDirection       = Mathf.Sin(bendDirectionRad);
            cosBendDirection       = Mathf.Cos(bendDirectionRad);
        }

        tubeCreatorStatus.foldoutShift = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutShift, "Shift");
        if (tubeCreatorStatus.foldoutShift)
        {
            float shiftT = EditorGUILayout.Slider(INDENT + "Magnitude (%)", tubeData.shift, 0.0f, 5000.0f);
            shiftT         = StepLength(shiftT);
            tubeData.shift = shiftT;
            shiftRate      = shiftT / 100.0f;

            float shiftDirectionT = EditorGUILayout.Slider(INDENT + "Direction", tubeData.shiftDirection, 0.0f, 360.0f);
            shiftDirectionT         = stepAngle(shiftDirectionT);
            tubeData.shiftDirection = shiftDirectionT;
            float shiftDirectionRad = Mathf.Deg2Rad * tubeData.shiftDirection;
            sinShiftDirection = Mathf.Sin(shiftDirectionRad);
            cosShiftDirection = Mathf.Cos(shiftDirectionRad);
        }

        tubeCreatorStatus.foldoutSetting = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutSetting, "Setting");
        if (tubeCreatorStatus.foldoutSetting)
        {
            tubeSetting.stepAngle = EditorGUILayout.FloatField(INDENT + "Step Angle", tubeSetting.stepAngle);
            if (tubeSetting.stepAngle < MIN_STEP_ANGLE)
            {
                tubeSetting.stepAngle = MIN_STEP_ANGLE;
            }
            if (tubeSetting.stepAngle > 360.0f)
            {
                tubeSetting.stepAngle = 360.0f;
            }

            tubeSetting.stepPercent = EditorGUILayout.FloatField(INDENT + "Step %", tubeSetting.stepPercent);
            if (tubeSetting.stepPercent < MIN_STEP_PERCENT)
            {
                tubeSetting.stepPercent = MIN_STEP_PERCENT;
            }

            EditorGUILayout.BeginHorizontal();
            {
                tubeSetting.saveFolder = EditorGUILayout.TextField(INDENT + "Save Folder", tubeSetting.saveFolder);
                tubeSetting.saveFolder = FormatSaveFolder(tubeSetting.saveFolder);
                if (GUILayout.Button("Browse", GUILayout.Width(60)))
                {
                    string folder = tubeSetting.saveFolder;
                    if (!System.IO.Directory.Exists(folder))
                    {
                        folder = DFTubeSetting.DEFAULT_SAVE_FOLDER;
                        if (!System.IO.Directory.Exists(folder))
                        {
                            folder = "";
                        }
                    }
                    string dir  = "";
                    string name = "";
                    if (folder.Length > 0)
                    {
                        dir  = Path.GetDirectoryName(folder);
                        name = Path.GetFileName(folder);
                    }
                    folder = EditorUtility.SaveFolderPanel("Save Mesh", dir, name);
                    if (folder.Length > 0)
                    {
                        tubeSetting.saveFolder = FormatSaveFolder(folder);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        if (GUILayout.Button("Select", GUILayout.Height(25)))
        {
            CreatePreview(true);
            SceneView.lastActiveSceneView.FrameSelected();
        }

        if (!EditorApplication.isPlaying)
        {
            if (GUI.changed || tubeCreatorStatus.isEditStart)
            {
                tubeCreatorStatus.isEditStart = false;
                CreatePreview(true);
            }
        }

        if (GUILayout.Button("Create", GUILayout.Height(25)))
        {
            if (CheckAndCreateFolder(tubeSetting.saveFolder))
            {
                CreatePreview(true);
                string path = MakeAssetName(previewObj, tubeSetting.saveFolder);
                if (path.Length > 0)
                {
                    Mesh mesh = previewObj.GetComponent <MeshFilter>().sharedMesh;
                    mesh.name = previewObj.name;
                    AssetDatabase.CreateAsset(mesh, path);
                    AssetDatabase.SaveAssets();
                    CreatePreview(false);
                }
            }
        }
        EditorGUI.EndDisabledGroup();

        tubeCreatorStatus.shapeBak = tubeCreatorStatus.shape;
    }
    void SetPresetShapeData()
    {
        tubeDataList.tubeDatas.Clear();
        DFTubeData tubeData;

        tubeData = new DFTubeData();
        tubeData.name = "Tube";
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Half Tube";
        tubeData.angle = 180.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Cylinder";
        tubeData.thickness = 100.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Cone";
        tubeData.thickness = 100.0f;
        tubeData.curveField = AnimationCurve.Linear(0.0f, 0.0f, 1.0f, 1.0f);
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Rugby Ball";
        tubeData.thickness = 100.0f;
        tubeData.curveField = AnimationCurve.EaseInOut(0.0f, 0.0f, 1.0f, 1.0f);
        Keyframe key = tubeData.curveField[0];
        key.inTangent = 2.0f;
        key.outTangent = 2.0f;
        tubeData.curveField.MoveKey(0, key);
        tubeData.isReverse = true;
        tubeData.isMirror = true;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Bowl";
        tubeData.sizeY = 0.0f;
        tubeData.thickness = 10.0f;
        tubeData.angle = 180.0f;
        tubeData.bendDegree = 180.0f;
        tubeData.bendDirection = 90.0f;
        tubeData.shiftDirection = 180.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Donut";
        tubeData.sizeY = 4.0f;
        tubeData.sizeR = 0.2f;
        tubeData.thickness = 100.0f;
        tubeData.bendDegree = 360;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Screw";
        tubeData.divisionY = 40;
        tubeData.sizeY = 10.0f;
        tubeData.sizeR = 0.2f;
        tubeData.thickness = 100.0f;
        tubeData.bendDegree = 360.0f * 3;
        tubeData.shift = 1000.0f;
        tubeDataList.tubeDatas.Add(tubeData);

        tubeData = new DFTubeData();
        tubeData.name = "Pyramid";
        tubeData.divisionY = 40;
        tubeData.divisionR = 4;
        tubeData.sizeY = 1.0f;
        tubeData.sizeR = 1.0f;
        tubeData.thickness = 100.0f;
        tubeData.curveField = AnimationCurve.Linear(0.0f, 0.0f, 1.0f, 1.0f);
        tubeDataList.tubeDatas.Add(tubeData);
    }
    void OnGUI()
    {
        if (EditorApplication.isPlayingOrWillChangePlaymode) {
            if (!tubeCreatorStatus.isPlaying) {
                tubeCreatorStatus.isPlaying = true;
                DestroyPreviewObj();
                tubeCreatorStatus.isPreview = false;
                tubeCreatorStatus.isEditStart = false;
            }
        } else if (tubeCreatorStatus.isPlaying) {
            tubeCreatorStatus.isPlaying = false;
            if (!EditorApplication.isPlaying) {
                tubeCreatorStatus.isPlaying = false;
            }
            tubeCreatorStatus.isPreview = true;
            tubeCreatorStatus.isEditStart = true;
        }

        EditorGUILayout.Space();

        EditorGUI.BeginDisabledGroup(tubeCreatorStatus.isPlaying == true);

        if (tubeCreatorStatus.shapeNames == null) {
            SetPresetShapeData();
            MakeShapeNameList();
        }
        tubeCreatorStatus.shape = EditorGUILayout.Popup("Preset Shape", tubeCreatorStatus.shape, tubeCreatorStatus.shapeNames);

        bool shapeChanged = (tubeCreatorStatus.shape != tubeCreatorStatus.shapeBak);

        tubeData.makeSurface = EditorGUILayout.MaskField("Surface", tubeData.makeSurface, new string[]{"Outside", "Inside", "Side End 1", "Side End 2", "Top End", "Bottom End"});

        if ((!EditorApplication.isPlaying) && shapeChanged) {
            tubeData.Reset();
            DestroyPreviewObj();

            if (tubeDataList.tubeDatas.Count > tubeCreatorStatus.shape) {
                tubeData = tubeDataList.tubeDatas[tubeCreatorStatus.shape].Get();
            }
        }

        tubeCreatorStatus.foldoutDivision = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutDivision, "Division");
        if (tubeCreatorStatus.foldoutDivision) {
            tubeData.divisionY = EditorGUILayout.IntSlider(INDENT + "Height", tubeData.divisionY, 1, 40);

            tubeData.divisionR = EditorGUILayout.IntSlider(INDENT + "Side", tubeData.divisionR, 1, 40);
        }

        tubeCreatorStatus.foldoutSize = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutSize, "Basic Size");
        if (tubeCreatorStatus.foldoutSize) {
            tubeData.sizeY = EditorGUILayout.FloatField(INDENT + "Height", tubeData.sizeY);
            if (tubeData.sizeY < MIN_SIZE) {
                tubeData.sizeY = MIN_SIZE;
            }

            tubeData.sizeR = EditorGUILayout.FloatField(INDENT + "Radius", tubeData.sizeR);
            if (tubeData.sizeR < MIN_SIZE) {
                tubeData.sizeR = MIN_SIZE;
            }

            float thicknessT = EditorGUILayout.Slider(INDENT + "Thickness (%)", tubeData.thickness, 0.0f, 100.0f);
            thicknessT = StepLength(thicknessT);
            tubeData.thickness = thicknessT;
            thicknessRate = thicknessT / 100.0f;

            float angleT = EditorGUILayout.Slider(INDENT + "Angle", tubeData.angle, 0.0f, 360.0f);
            angleT = stepAngle(angleT);
            tubeData.angle = angleT;
            is360 = (tubeData.angle == 360.0f)?true:false;
        }

        tubeCreatorStatus.foldoutCurve = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutCurve, "Side Shape");
        if (tubeCreatorStatus.foldoutCurve) {
            tubeData.curveField = EditorGUILayout.CurveField(INDENT + "Curve", tubeData.curveField, Color.green, new Rect(0.0f, 0.0f, 1.0f, 1.0f));

            tubeData.isReverse = EditorGUILayout.Toggle(INDENT + "Reverse", tubeData.isReverse);

            tubeData.isMirror = EditorGUILayout.Toggle(INDENT + "Mirror", tubeData.isMirror);
        }

        tubeCreatorStatus.foldoutBend = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutBend, "Bend");
        if (tubeCreatorStatus.foldoutBend) {
            float bendDegreeT = EditorGUILayout.Slider(INDENT + "Angle", tubeData.bendDegree, 0.0f, 360.0f * 3);
            bendDegreeT = stepAngle(bendDegreeT);
            tubeData.bendDegree = bendDegreeT;
            bendRad = tubeData.bendDegree * Mathf.Deg2Rad;

            float bendDirectionT = EditorGUILayout.Slider(INDENT + "Direction", tubeData.bendDirection, 0.0f, 360.0f);
            bendDirectionT = stepAngle(bendDirectionT);
            tubeData.bendDirection = bendDirectionT;
            bendDirectionRad = Mathf.Deg2Rad * tubeData.bendDirection;
            sinBendDirection = Mathf.Sin(bendDirectionRad);
            cosBendDirection = Mathf.Cos(bendDirectionRad);
        }

        tubeCreatorStatus.foldoutShift = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutShift, "Shift");
        if (tubeCreatorStatus.foldoutShift) {
            float shiftT = EditorGUILayout.Slider(INDENT + "Magnitude (%)", tubeData.shift, 0.0f, 5000.0f);
            shiftT = StepLength(shiftT);
            tubeData.shift = shiftT;
            shiftRate = shiftT / 100.0f;

            float shiftDirectionT = EditorGUILayout.Slider(INDENT + "Direction", tubeData.shiftDirection, 0.0f, 360.0f);
            shiftDirectionT = stepAngle(shiftDirectionT);
            tubeData.shiftDirection = shiftDirectionT;
            float shiftDirectionRad = Mathf.Deg2Rad * tubeData.shiftDirection;
            sinShiftDirection = Mathf.Sin(shiftDirectionRad);
            cosShiftDirection = Mathf.Cos(shiftDirectionRad);
        }

        tubeCreatorStatus.foldoutSetting = EditorGUILayout.Foldout(tubeCreatorStatus.foldoutSetting, "Setting");
        if (tubeCreatorStatus.foldoutSetting) {
            tubeSetting.stepAngle = EditorGUILayout.FloatField(INDENT + "Step Angle", tubeSetting.stepAngle);
            if (tubeSetting.stepAngle < MIN_STEP_ANGLE) {
                tubeSetting.stepAngle = MIN_STEP_ANGLE;
            }
            if (tubeSetting.stepAngle > 360.0f) {
                tubeSetting.stepAngle = 360.0f;
            }

            tubeSetting.stepPercent = EditorGUILayout.FloatField(INDENT + "Step %", tubeSetting.stepPercent);
            if (tubeSetting.stepPercent < MIN_STEP_PERCENT) {
                tubeSetting.stepPercent = MIN_STEP_PERCENT;
            }

            EditorGUILayout.BeginHorizontal();
            {
                tubeSetting.saveFolder = EditorGUILayout.TextField(INDENT + "Save Folder", tubeSetting.saveFolder);
                tubeSetting.saveFolder = FormatSaveFolder(tubeSetting.saveFolder);
                if (GUILayout.Button("Browse", GUILayout.Width(60))) {
                    string folder = tubeSetting.saveFolder;
                    if (!System.IO.Directory.Exists(folder)) {
                        folder = DFTubeSetting.DEFAULT_SAVE_FOLDER;
                        if (!System.IO.Directory.Exists(folder)) {
                            folder = "";
                        }
                    }
                    string dir = "";
                    string name = "";
                    if (folder.Length > 0) {
                        dir = Path.GetDirectoryName(folder);
                        name = Path.GetFileName(folder);
                    }
                    folder = EditorUtility.SaveFolderPanel("Save Mesh", dir, name);
                    if (folder.Length > 0) {
                        tubeSetting.saveFolder = FormatSaveFolder(folder);
                    }
                }
            }
            EditorGUILayout.EndHorizontal();
        }

        if (GUILayout.Button("Select", GUILayout.Height(25))) {
            CreatePreview(true);
            SceneView.lastActiveSceneView.FrameSelected();
        }

        if (!EditorApplication.isPlaying) {
            if (GUI.changed || tubeCreatorStatus.isEditStart) {
                tubeCreatorStatus.isEditStart = false;
                CreatePreview(true);
            }
        }

        if (GUILayout.Button("Create", GUILayout.Height(25))) {
            if (CheckAndCreateFolder(tubeSetting.saveFolder)) {
                CreatePreview(true);
                string path = MakeAssetName(previewObj, tubeSetting.saveFolder);
                if (path.Length > 0) {
                    Mesh mesh = previewObj.GetComponent<MeshFilter>().sharedMesh;
                    mesh.name = previewObj.name;
                    AssetDatabase.CreateAsset(mesh, path);
                    AssetDatabase.SaveAssets();
                    CreatePreview(false);
                }
            }
        }
        EditorGUI.EndDisabledGroup();

        tubeCreatorStatus.shapeBak = tubeCreatorStatus.shape;
    }