/// <summary>
    /// Will create a child GameObject to store created prefabs
    /// </summary>
    private void OnEnable()
    {
        string generatedName     = "generated by " + GetType().Name;
        var    generatedTranform = transform.Find(generatedName);

        generated = generatedTranform != null ? generatedTranform.gameObject : UOUtility.Create(generatedName, gameObject);

        spline = GetComponentInParent <Spline>();
        spline.NodeListChanged += (s, e) => {
            toUpdate = true;
            foreach (CubicBezierCurve curve in spline.GetCurves())
            {
                curve.Changed.AddListener(() => toUpdate = true);
            }
        };

        foreach (CubicBezierCurve curve in spline.GetCurves())
        {
            curve.Changed.AddListener(() => toUpdate = true);
        }
    }
Esempio n. 2
0
    private void Init()
    {
        if (m_Spline != null && m_Mesh != null && m_Material != null)
        {
            string generatedName     = "Mesh";
            var    generatedTranform = transform.Find(generatedName);
            m_Generated = generatedTranform != null ? generatedTranform.gameObject : UOUtility.Create(generatedName, gameObject,
                                                                                                      typeof(MeshFilter),
                                                                                                      typeof(MeshRenderer),
                                                                                                      typeof(MeshBender));

            m_Generated.GetComponent <MeshRenderer>().material = m_Material;

            meshBender = m_Generated.GetComponent <MeshBender>();
            // m_Spline = GetComponent<Spline>();

            meshBender.Source = SourceMesh.Build(m_Mesh)
                                .Rotate(Quaternion.Euler(m_Rotation))
                                .Scale(m_Scale);
            meshBender.Mode = MeshBender.FillingMode.Once;
            meshBender.SetInterval(m_Spline, 0);
        }
    }
Esempio n. 3
0
    private void Init()
    {
        //Block of code came from Spline asset
        string generatedName     = "generated by " + GetType().Name;
        var    generatedTranform = transform.Find(generatedName);

        generatedModelGameObject = generatedTranform != null ? generatedTranform.gameObject : UOUtility.Create(generatedName, gameObject,
                                                                                                               typeof(MeshFilter),
                                                                                                               typeof(MeshRenderer),
                                                                                                               typeof(MeshBender));

        generatedModelGameObject.GetComponent <MeshRenderer>().material = material;

        meshBender = generatedModelGameObject.GetComponent <MeshBender>();
        spline     = GetComponent <Spline>();

        meshBender.Source = SourceMesh.Build(mesh)
                            .Rotate(Quaternion.Euler(rotation))
                            .Scale(scale);
        meshBender.Mode = MeshBender.FillingMode.StretchToInterval;
        meshBender.SetInterval(spline, 0, 0.01f);
    }
Esempio n. 4
0
    void Init()
    {
        if (m_Spline != null && m_Prefab != null)
        {
            if (m_Generated == null)
            {
                string generatedName     = "Generated Objects";
                var    generatedTranform = transform.Find(generatedName);
                m_Generated = generatedTranform != null ? generatedTranform.gameObject : UOUtility.Create(generatedName, gameObject);
            }

            m_Spline.NodeListChanged += (s, e) =>
            {
                toUpdate = true;
                foreach (CubicBezierCurve curve in m_Spline.GetCurves())
                {
                    curve.Changed.AddListener(() => toUpdate = true);
                }
            };
            foreach (CubicBezierCurve curve in m_Spline.GetCurves())
            {
                curve.Changed.AddListener(() => toUpdate = true);
            }
        }
    }