Namespace: MDPackage.Geometry
Base geometry class for all the geometry-related instances. Implement this base class to any script that will constantly work with Unity-meshes and frequent updates will be necessary.
Please read the APi below carefully as the setup for classes that inherit from this base class is slightly different.
Public Methods
public static T CreateGeometry<T>(GameObject entry, bool updateJustOnce = true)
public static void CreateGeometryAndDispose<T>(GameObject entry, string geometryName = "NewGeometryMesh")
public static GameObject CreateGeometryAndDispose<T>(string gameObjectName = "NewGeometryObject", string geometryName = "NewGeometryMesh", bool prepareMaterial = true)
public static GameObject PrepareGeometryInstance(GameObject sender, bool selectAndJumpToCamera = true)
public void MDGeometryBase_ChangeResolution(float res)
public void MDGeometryBase_ChangeMeshCenter(bool centerGeo)
public void MDGeometryBase_FlipTriangles()
Public Fields and Properties
public int geometryResolution = 1;
public bool geometryUseResolution = true;
public bool geometryCenterMesh = true;
public Vector3 geometryOffset = Vector3.zero;
public bool IsInitialized { get; }
public string GeometryName { get; }
public MDVertices GeometryVertices { get; }
public MDTriangles GeometryTriangles { get; }
public MDUvs GeometryUVs { get; }
Examples & Setup
All the geometry that inherit from this base class must be initialized in a certain way.
You can either simply call gameObject.AddComponent() or call a static method MD_GeometryBase.CreateGeometryAndDispose(Advanced data...).
using UnityEngine;
using MDPackage.Geometry;
public class SampleScript : MonoBehaviour
{
private MDG_Cone cone;
private void Start()
{
cone = MD_GeometryBase.CreateGeometry<MDG_Cone>(gameObject);
}
}
The gameObject that receives this geometry does not need to have MeshFilter/MeshRenderer, this is handled automatically. However the materials will be empty.
If you would like to add a certain geometry script without using the actual script and only generate a mesh, you can use CreateGeometryAndDispose static method.
using UnityEngine;
using MDPackage.Geometry;
public class SampleScript : MonoBehaviour
{
private void Start()
{
MD_GeometryBase.CreateGeometryAndDispose<MDG_Cone>(gameObject);
}
}
Another way of adding the geometry and disposing the script is to create a brand new gameObject.
using UnityEngine;
using MDPackage.Geometry;
public class SampleScript : MonoBehaviour
{
private void Start()
{
GameObject newGm = MD_GeometryBase.CreateGeometryAndDispose<MDG_Cone>();
}
}