30-05-2019, 12:51 AM
I am trying to make obi cloth on script. I saw scripting Actors of user manual.
What is wrong with that? I had three errors.
Assets\SetupCloth.cs(21,38): error CS0411: The type arguments for method 'GameObject.GetComponent<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Assets\SetupCloth.cs(22,40): error CS0411: The type arguments for method 'GameObject.GetComponent<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Assets\SetupCloth.cs(25,68): error CS0103: The name 'sourceTopology' does not exist in the current context
Code:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Obi;
public class SetupCloth : MonoBehaviour
{
GameObject obj;
ObiActor actor;
public ObiSolver solver;
void Start()
{
obj = GameObject.Find("cloth");
Mesh mesh = obj.GetComponent<MeshFilter>().sharedMesh;
GameObject clothObject = new GameObject("cloth", typeof(ObiSolver),typeof(ObiCloth));
// get references to all components:
ObiCloth cloth = clothObject.GetComponent();
ObiSolver solver = clothObject.GetComponent();
// generate the topology:
ObiMeshTopology topology = ScriptableObject.CreateInstance(sourceTopology);
topology.InputMesh = mesh;
topology.Generate();
// set the cloth topology and solver:
cloth.Solver = solver;
cloth.SharedTopology = topology;
}
}
Assets\SetupCloth.cs(21,38): error CS0411: The type arguments for method 'GameObject.GetComponent<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Assets\SetupCloth.cs(22,40): error CS0411: The type arguments for method 'GameObject.GetComponent<T>()' cannot be inferred from the usage. Try specifying the type arguments explicitly.
Assets\SetupCloth.cs(25,68): error CS0103: The name 'sourceTopology' does not exist in the current context