Пример #1
0
 public void SetAllBorderWidth(float width)
 {
     for (int i = 0; i < tobogganParts.Length; i++)
     {
         ScriptableControlPoints scriptableCP = tobogganParts[i];
         scriptableCP.SetAllBorderWidth(width);
     }
 }
Пример #2
0
 public void SetAllBorderHeight(float height)
 {
     for (int i = 0; i < tobogganParts.Length; i++)
     {
         ScriptableControlPoints scriptableCP = tobogganParts[i];
         scriptableCP.SetAllBorderHeight(height);
     }
 }
Пример #3
0
    public void SaveModel()
    {
        ScriptableControlPoints scriptable = ScriptableObject.CreateInstance <ScriptableControlPoints>();

        scriptable.ctrlPoints  = controlPoints;
        scriptable.pipesParams = new List <ScriptableControlPoints.PipeParams>();
        for (int i = 0; i < transform.childCount; i++)
        {
            CustomPipe child = transform.GetChild(i).GetComponent <CustomPipe>();
            foreach (MeshCollider meshCollider in child.gameObject.GetComponents <MeshCollider>())
            {
                Destroy(meshCollider);
            }
            //gameObject.AddComponent<MeshCollider>();
            foreach (MeshCollider meshCollider in child.transform.GetChild(0).GetComponents <MeshCollider>())
            {
                Destroy(meshCollider);
            }
            child.transform.GetChild(0).gameObject.AddComponent <MeshCollider>();
            //layer obstacle = 9
            child.transform.GetChild(0).gameObject.layer = 9;

            ScriptableControlPoints.PipeParams pipeParams = new ScriptableControlPoints.PipeParams();
            pipeParams.bezierPoints  = child.bezierPoints.ToArray();
            pipeParams.minArchNum    = child.minArchNum;
            pipeParams.maxArchNum    = child.maxArchNum;
            pipeParams.startAngle    = child.startAngle;
            pipeParams.endAngle      = child.endAngle;
            pipeParams.pipeWidth     = child.pipeWidth;
            pipeParams.thickness     = child.thickness;
            pipeParams.borderWidth   = child.borderWidth;
            pipeParams.noBorderLeft  = child.noBorderLeft;
            pipeParams.noBorderRight = child.noBorderRight;
            pipeParams.shapeIndex    = child.shapeIndex;
            scriptable.pipesParams.Add(pipeParams);
        }
        AssetDatabase.CreateAsset(scriptable, "Assets/Scripts/ScriptableObject/scriptableControlPoints_" + Mathf.Round(Time.time * 10000f) + ".asset");
        AssetDatabase.SaveAssets();
        AssetDatabase.Refresh();
        EditorUtility.SetDirty(scriptable);
    }