Quick Start Guide
Getting started with the MeshifAI Scripting API is simply and easy to use. Let's dive into using it below.
Basic Usage
Here's a simple example to generate a 3D model from a text description:
using UnityEngine;
using MeshifAI.Core;
public class QuickStartExample : MonoBehaviour
{
private void Start()
{
// Generate a model with a simple description
Meshifai.GenerateModel(
"A futuristic spaceship",
OnModelGenerated
);
}
private void OnModelGenerated(GameObject model)
{
// Position the model in your scene
model.transform.SetParent(transform);
model.transform.localPosition = Vector3.zero;
// That's it! Your AI-generated model is ready to use
Debug.Log("Model generated successfully!");
}
}
Adding Error Handling
For more robust implementation, add error handling:
Meshifai.GenerateModel(
"A medieval castle",
OnModelGenerated,
OnGenerationError
);
private void OnGenerationError(string errorMessage)
{
Debug.LogError($"Generation failed: {errorMessage}");
}
Showing Progress Updates
Keep your users informed with progress updates:
Meshifai.GenerateModel(
"A fantasy sword",
OnModelGenerated,
OnGenerationError,
OnGenerationStatus
);
private void OnGenerationStatus(string status, float progress)
{
// Update your UI with the current generation status
Debug.Log($"{status} - {progress:P0} complete");
}
Accessing Model Metadata
Each generated model includes metadata about how it was created:
private void OnModelGenerated(GameObject model)
{
// Get the generation data component
ModelGenerationData data = model.GetComponent<ModelGenerationData>();
// Access generation parameters
Debug.Log($"Model prompt: {data.Prompt}");
Debug.Log($"Model variance: {data.Variance}");
Debug.Log($"Generated at: {data.GenerationTime}");
}
Now that you have a general understanding, you're ready to dive into the world of 3D Model generation. We look forward to see what you choose to build with it.
Last updated