Пример #1
0
    public override void OnInspectorGUI()
    {
        SaveAsset myTarget = (SaveAsset)target;

        DrawDefaultInspector();

        if (GUILayout.Button("Save Asset"))
        {
            myTarget.Save();
        }
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        // DrawDefaultInspector();
        var rect = EditorGUILayout.BeginHorizontal();
        var xx   = rect.x + (rect.width - ExtrudeSplineBanner.image.width) * 0.5f;

        GUI.Label(new Rect(xx, rect.y, ExtrudeSplineBanner.image.width, ExtrudeSplineBanner.image.height), ExtrudeSplineBanner);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        EditorGUILayout.LabelField("Extrude Settings", EditorStyles.boldLabel);

        EditorGUI.BeginChangeCheck();
        var extrudeHeight = EditorGUILayout.FloatField("Extrude height", Extrude.Height);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Extrude height changed");
            Extrude.Height = extrudeHeight;
            Extrude.DrawMeshOnEachBranch();

            EditorUtility.SetDirty(Extrude);
        }
        EditorGUI.BeginChangeCheck();
        var rings = EditorGUILayout.IntField("Rings", Extrude.Rings);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Rings changed");
            if (rings < 0)
            {
                rings = 0;
            }
            Extrude.Rings = rings;
            Extrude.DrawMeshOnEachBranch();

            EditorUtility.SetDirty(Extrude);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Shell Settings", EditorStyles.boldLabel);

        EditorGUI.BeginChangeCheck();
        var shell = EditorGUILayout.Toggle("Shell", Extrude.Shell);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Shell value changed");
            Extrude.Shell = shell;
            if (Extrude.Shell)
            {
                Extrude.CapHoles = true;
            }
            Extrude.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(Extrude);
        }

        if (Extrude.Shell)
        {
            EditorGUI.BeginChangeCheck();
            var shellPower = EditorGUILayout.FloatField("Shell power", Extrude.ShellPower);
            if (EditorGUI.EndChangeCheck())
            {
                Undo.RecordObject(Extrude, "Shell power  changed");
                Extrude.ShellPower = shellPower;
                Extrude.DrawMeshOnEachBranch();
                EditorUtility.SetDirty(Extrude);
            }
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Faces Settings", EditorStyles.boldLabel);
        EditorGUI.BeginChangeCheck();
        var CapHoles = EditorGUILayout.Toggle("Cap holes", Extrude.CapHoles);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Cap holes changed");
            Extrude.CapHoles = CapHoles;
            Extrude.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(Extrude);
        }
        EditorGUI.BeginChangeCheck();
        var twoSided = EditorGUILayout.Toggle("Two sided", Extrude.TwoSided);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Two sided changed");
            Extrude.TwoSided = twoSided;
            Extrude.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(Extrude);
        }
        var FlipFaces = EditorGUILayout.Toggle("Flip faces", Extrude.FlipFaces);

        if (FlipFaces != Extrude.FlipFaces)
        {
            Undo.RecordObject(Extrude, "Flip faces changed");
            Extrude.FlipFaces = FlipFaces;
            Extrude.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(Extrude);
        }
        EditorGUILayout.BeginHorizontal();
        EditorGUI.BeginChangeCheck();
        var curvature = EditorGUILayout.CurveField("Curvature", Extrude.Curvature, Color.green, new Rect(0, -1, 1, 2));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Curvature changed");
            Extrude.Curvature = curvature;
            Extrude.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(Extrude);
        }
        EditorGUI.BeginChangeCheck();
        var curvaturePower = EditorGUILayout.FloatField(Extrude.CurvaturePower, GUILayout.MaxWidth(70));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Curvature power value changed");
            Extrude.CurvaturePower = curvaturePower;
            Extrude.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(Extrude);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Material Settings", EditorStyles.boldLabel);

        EditorGUI.BeginChangeCheck();
        var mat = (Material)EditorGUILayout.ObjectField("Material", Extrude.Material, typeof(Material), true);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Material changed");
            Extrude.Material = mat;
            Extrude.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(Extrude);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Export settings", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();

        EditorGUI.BeginChangeCheck();
        var assetName = EditorGUILayout.TextField("Asset name", Extrude.AssetName);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(Extrude, "Asset name changed");
            Extrude.AssetName = assetName;
            EditorUtility.SetDirty(Extrude);
        }

        if (GUILayout.Button("Export Asset"))
        {
            SaveAsset.Save(Extrude.gameObject, Extrude.AssetName);
        }

        EditorGUILayout.EndHorizontal();
    }
Пример #3
0
    public override void OnInspectorGUI()
    {
        // DrawDefaultInspector();
        var rect = EditorGUILayout.BeginHorizontal();
        var xx   = rect.x + (rect.width - PlaneMeshBanner.image.width) * 0.5f;

        GUI.Label(new Rect(xx, rect.y, PlaneMeshBanner.image.width, PlaneMeshBanner.image.height), PlaneMeshBanner);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (PlaneMesh.SplinePlus.SPData.DictBranches.Count == 0 || PlaneMesh.SplinePlus == null)
        {
            return;
        }
        var branch = PlaneMesh.SplinePlus.SPData.DictBranches[PlaneMesh.SplinePlus.SPData.Selections._BranchKey];

        if (branch.Nodes.Count == 0)
        {
            return;
        }

        EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        EditorGUI.BeginChangeCheck();

        var curve = EditorGUILayout.CurveField("Width", PlaneMesh.BranchData[PlaneMesh.SplinePlus.SPData.Selections._BranchIndex].Curve, Color.green, new Rect(0, 0, 1, 1));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "Width changed");
            PlaneMesh.BranchData[PlaneMesh.SplinePlus.SPData.Selections._BranchIndex].Curve = curve;
            PlaneMesh.DrawMeshOnEachBranch();

            EditorUtility.SetDirty(PlaneMesh);
        }
        EditorGUI.BeginChangeCheck();
        var MaxWidth = EditorGUILayout.FloatField(PlaneMesh.MaxWidth, GUILayout.MaxWidth(80));

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "Max width changed");
            PlaneMesh.MaxWidth = MaxWidth;
            PlaneMesh.DrawMeshOnEachBranch();

            EditorUtility.SetDirty(PlaneMesh);
        }
        EditorGUILayout.EndHorizontal();
        EditorGUI.BeginChangeCheck();
        var meshDecal = EditorGUILayout.FloatField("Offset", PlaneMesh.BranchData[PlaneMesh.SplinePlus.SPData.Selections._BranchIndex].BranchMeshDecal);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "Offset changed");
            PlaneMesh.BranchData[PlaneMesh.SplinePlus.SPData.Selections._BranchIndex].BranchMeshDecal = meshDecal;
            PlaneMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(PlaneMesh);
        }

        EditorGUI.BeginChangeCheck();
        var flipFaces = EditorGUILayout.Toggle("Flip faces", PlaneMesh.FlipFaces);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "Flip faces changed");
            PlaneMesh.FlipFaces = flipFaces;
            PlaneMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(PlaneMesh);
        }
        EditorGUI.BeginChangeCheck();
        var twoSided = EditorGUILayout.Toggle("Two sided", PlaneMesh.TwoSided);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "Two sided changed");
            PlaneMesh.TwoSided = twoSided;
            PlaneMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(PlaneMesh);
        }
        EditorGUI.BeginChangeCheck();
        var brushTextureType = EditorGUILayout.Toggle("Brush texture type", PlaneMesh.IsBrushTextureType);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "Brush texture type changed");
            PlaneMesh.IsBrushTextureType = brushTextureType;
            PlaneMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(PlaneMesh);
        }
        EditorGUI.BeginChangeCheck();
        var material = (Material)EditorGUILayout.ObjectField("material", PlaneMesh.Material, typeof(Material), true);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "materialchanged");
            PlaneMesh.Material = material;
            PlaneMesh.MeshRenderer.sharedMaterial = PlaneMesh.Material;
            EditorUtility.SetDirty(PlaneMesh);
        }
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Export settings", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();

        EditorGUI.BeginChangeCheck();
        var assetName = EditorGUILayout.TextField("Asset name", PlaneMesh.AssetName);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(PlaneMesh, "Asset name changed");
            PlaneMesh.AssetName = assetName;
            EditorUtility.SetDirty(PlaneMesh);
        }
        if (GUILayout.Button("Export asset"))
        {
            SaveAsset.Save(PlaneMesh.gameObject, PlaneMesh.AssetName);
        }

        EditorGUILayout.EndHorizontal();
    }
Пример #4
0
    public override void OnInspectorGUI()
    {
        // DrawDefaultInspector();
        var rect = EditorGUILayout.BeginHorizontal();
        var xx   = rect.x + (rect.width - TubeMeshBanner.image.width) * 0.5f;

        GUI.Label(new Rect(xx, rect.y, TubeMeshBanner.image.width, TubeMeshBanner.image.height), TubeMeshBanner);
        EditorGUILayout.EndHorizontal();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();

        if (TubeMesh.SplinePlus.SPData.DictBranches.Count == 0)
        {
            return;
        }
        var branch = TubeMesh.SplinePlus.SPData.DictBranches[TubeMesh.SplinePlus.SPData.Selections._BranchKey];

        if (branch.Nodes.Count == 0)
        {
            return;
        }

        EditorGUILayout.LabelField("Settings", EditorStyles.boldLabel);
        EditorGUI.BeginChangeCheck();
        var radius = EditorGUILayout.FloatField("Radius", TubeMesh.Radius);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(TubeMesh, "Radius changed");
            TubeMesh.Radius = radius;
            TubeMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(TubeMesh);
        }
        EditorGUI.BeginChangeCheck();
        var segments = EditorGUILayout.IntField("Segments", TubeMesh.Segments);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(TubeMesh, "Segments changed");
            if (segments < 1)
            {
                segments = 1;
            }
            TubeMesh.Segments = segments;
            TubeMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(TubeMesh);
        }
        EditorGUI.BeginChangeCheck();
        var flipFaces = EditorGUILayout.Toggle("Flip faces", TubeMesh.FlipFaces);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(TubeMesh, "Flip faces changed");
            TubeMesh.FlipFaces = flipFaces;
            TubeMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(TubeMesh);
        }
        EditorGUI.BeginChangeCheck();
        var twoSided = EditorGUILayout.Toggle("Two sided", TubeMesh.TwoSided);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(TubeMesh, "Two sided changed");
            TubeMesh.TwoSided = twoSided;
            TubeMesh.DrawMeshOnEachBranch();
            EditorUtility.SetDirty(TubeMesh);
        }
        EditorGUI.BeginChangeCheck();
        var material = (Material)EditorGUILayout.ObjectField("material", TubeMesh.Material, typeof(Material), true);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(TubeMesh, "materialchanged");
            TubeMesh.Material = material;
            TubeMesh.MeshRenderer.sharedMaterial = TubeMesh.Material;
            EditorUtility.SetDirty(TubeMesh);
        }

        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.Space();
        EditorGUILayout.LabelField("Export settings", EditorStyles.boldLabel);
        EditorGUILayout.BeginHorizontal();
        EditorGUI.BeginChangeCheck();
        var assetName = EditorGUILayout.TextField("Asset name", TubeMesh.AssetName);

        if (EditorGUI.EndChangeCheck())
        {
            Undo.RecordObject(TubeMesh, "Asset name changed");
            TubeMesh.AssetName = assetName;
            EditorUtility.SetDirty(TubeMesh);
        }
        if (GUILayout.Button("Export asset"))
        {
            SaveAsset.Save(TubeMesh.gameObject, TubeMesh.AssetName);
        }

        EditorGUILayout.EndHorizontal();
    }