Skip to main content

Indie game storeFree gamesFun gamesHorror games
Game developmentAssetsComics
SalesBundles
Jobs
TagsGame Engines

unity3D system plug-ins

A topic by RawFormula created 86 days ago Views: 138 Replies: 2
Viewing posts 1 to 3

ai projects [chatgpt, deepseek etc] NOT TESTED. NO GUARANTEES.

🎮 How To Use

  1. Select a Mesh object in the scene

  2. Open
    Tools → Simple Mesh Modifier

  3. Set Selection Radius

  4. Click Select Vertices by Radius

  5. Adjust Scale

  6. Click Scale Selected Vertices

Red dots show selected vertices in Scene View.


using UnityEngine;

using UnityEditor;

using System.Collections.Generic;

public class SimpleMeshModifier : EditorWindow

{

    GameObject targetObject;

    Mesh mesh;

    Vector3[] vertices;

    float selectionRadius = 0.5f;

    Vector3 scale = Vector3.one * 1.2f;

    List<int> selectedVertices = new List<int>();

    [MenuItem("Tools/Simple Mesh Modifier")]

    static void Open()

    {

        GetWindow<SimpleMeshModifier>("Mesh Modifier");

    }

    void OnGUI()

    {

        GUILayout.Label("Simple Mesh Modifier", EditorStyles.boldLabel);

        targetObject = (GameObject)EditorGUILayout.ObjectField(

            "Target Object",

            targetObject,

            typeof(GameObject),

            true

        );

        selectionRadius = EditorGUILayout.FloatField("Selection Radius", selectionRadius);

        scale = EditorGUILayout.Vector3Field("Scale", scale);

        if (GUILayout.Button("Select Vertices by Radius"))

        {

            SelectVertices();

        }

        if (GUILayout.Button("Scale Selected Vertices"))

        {

            ScaleVertices();

        }

        GUILayout.Label($"Selected Vertices: {selectedVertices.Count}");

    }

    void SelectVertices()

    {

        selectedVertices.Clear();

        if (!ValidateMesh()) return;

        Vector3 center = targetObject.transform.position;

        for (int i = 0; i < vertices.Length; i++)

        {

            Vector3 worldPos = targetObject.transform.TransformPoint(vertices[i]);

            if (Vector3.Distance(worldPos, center) <= selectionRadius)

            {

                selectedVertices.Add(i);

            }

        }

        SceneView.RepaintAll();

    }

    void ScaleVertices()

    {

        if (!ValidateMesh() || selectedVertices.Count == 0) return;

        Undo.RecordObject(mesh, "Scale Vertices");

        Vector3 center = Vector3.zero;

        foreach (int i in selectedVertices)

            center += vertices[i];

        center /= selectedVertices.Count;

        foreach (int i in selectedVertices)

        {

            Vector3 dir = vertices[i] - center;

            vertices[i] = center + Vector3.Scale(dir, scale);

        }

        mesh.vertices = vertices;

        mesh.RecalculateNormals();

        mesh.RecalculateBounds();

        EditorUtility.SetDirty(mesh);

    }

    bool ValidateMesh()

    {

        if (!targetObject) return false;

        MeshFilter mf = targetObject.GetComponent<MeshFilter>();

        if (!mf || !mf.sharedMesh) return false;

        // Duplicate mesh so original asset is not modified

        mesh = Instantiate(mf.sharedMesh);

        mf.sharedMesh = mesh;

        vertices = mesh.vertices;

        return true;

    }

    void OnSceneGUI(SceneView sceneView)

    {

        if (!targetObject || vertices == null) return;

        Handles.color = Color.red;

        foreach (int i in selectedVertices)

        {

            Vector3 worldPos = targetObject.transform.TransformPoint(vertices[i]);

            Handles.SphereHandleCap(

                0,

                worldPos,

                Quaternion.identity,

                0.02f,

                EventType.Repaint

            );

        }

    }

    void OnEnable()

    {

        SceneView.duringSceneGui += OnSceneGUI;

    }

    void OnDisable()

    {

        SceneView.duringSceneGui -= OnSceneGUI;

    }

}

tested

ComponentCopyTool .cs

component copier for unity3D  

[needs to be put in Editor folder]

<quote>

using UnityEngine;

using UnityEditor;

public class ComponentCopyTool : EditorWindow

{

    Transform source;

    Transform target;

    [MenuItem("Tools/Component Copy Tool")]

    static void Init()

    {

        GetWindow<ComponentCopyTool>("Component Copier");

    }

    void OnGUI()

    {

        GUILayout.Label("Copy Components", EditorStyles.boldLabel);

        source = (Transform)EditorGUILayout.ObjectField("Source", source, typeof(Transform), true);

        target = (Transform)EditorGUILayout.ObjectField("Target", target, typeof(Transform), true);

        if (GUILayout.Button("Copy Components"))

        {

            CopyAll();

        }

    }

    void CopyAll()

    {

        if (source == null || target == null)

        {

            Debug.LogError("Assign source and target.");

            return;

        }

        Component[] components = source.GetComponents<Component>();

        foreach (Component comp in components)

        {

            if (comp is Transform)

                continue;

            UnityEditorInternal.ComponentUtility.CopyComponent(comp);

            UnityEditorInternal.ComponentUtility.PasteComponentAsNew(target.gameObject);

        }

        Debug.Log("Copied successfully");

    }

}