Exemplo n.º 1
0
        void Start()
        {
            // Add TubeRendeder component.
            TubeRenderer tube = gameObject.AddComponent <TubeRenderer>();

            // Optimise for realtime manipulation.
            tube.MarkDynamic();

            // Set a texture and a uv mapping.
            tube.GetComponent <Renderer>().material.mainTexture          = Helpers.CreateTileTexture(12);
            tube.GetComponent <Renderer>().material.mainTexture.wrapMode = TextureWrapMode.Repeat;
            tube.uvRect    = new Rect(0, 0, 6, 1);
            tube.uvRectCap = new Rect(0, 0, 4 / 12f, 4 / 12f);

            // Add a SplineMaker component.
            _splineMaker = gameObject.AddComponent <SplineMaker>();

            // Set the spline resolution.
            _splineMaker.pointsPerSegment = 16;

            // Route curve points from spline to tube.
            _splineMaker.onUpdated.AddListener((points) => tube.points = points);

            // Create anchor points for curve.
            _anchorPoints = new Vector3[6];
            for (int a = 0; a < _anchorPoints.Length; a++)
            {
                _anchorPoints[a] = new Vector3();
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Конструктор класса MainWindow.
        /// </summary>
        public MainWindow()
        {
            InitializeComponent();

            drawingClass      = new DrawingClass(this, splineCollection);
            openSaveDialogs   = new OpenSaveDialogs(this, drawingClass, splineCollection);
            splineMaker       = new SplineMaker(splineCollection);
            pointsListDialogs = new PointsListDialogs(this)
            {
                splineCollection = splineCollection
            };

            // Установка минимальных размеров окна - размер монитора.
            DeBoorsSplinesAppWindow.MinHeight =
                SystemParameters.PrimaryScreenHeight;
            DeBoorsSplinesAppWindow.MinWidth =
                SystemParameters.PrimaryScreenWidth;

            MessageBox.Show("Не рекомендуется вводить больше 50 опорных точек.\n" +
                            "Если Вам всё же это понадобится в ходе работы, не гарантируется" +
                            " быстрая работа программы в силу ограниченных " +
                            "возможностей центрального процессора.", "Предупреждение перед" +
                            " началом работы",
                            MessageBoxButton.OK, MessageBoxImage.Information);
        }
Exemplo n.º 3
0
 void Awake()
 {
     if (instance != null)
     {
         if (instance != this)
         {
             Destroy(gameObject);
         }
     }
     instance = this;
 }
    void OnEnable()
    {
        _spline = target as SplineMaker;

        _pointsPerSegment = serializedObject.FindProperty("_pointsPerSegment");
        _loop             = serializedObject.FindProperty("_loop");
        _onUpdated        = serializedObject.FindProperty("_onUpdated");
        _anchorPoints     = serializedObject.FindProperty("_anchorPoints");

        _anchorPointsList = new ReorderableList(serializedObject, _anchorPoints, true, true, true, true);
        _anchorPointsList.drawElementCallback =
            (Rect rect, int index, bool isActive, bool isFocused) => {
            SerializedProperty pointProp = _anchorPointsList.serializedProperty.GetArrayElementAtIndex(index);
            rect.y                += 2;
            rect.height            = EditorGUIUtility.singleLineHeight;
            pointProp.vector3Value = EditorGUI.Vector3Field(rect, "Anchor " + index, pointProp.vector3Value);
        };
        _anchorPointsList.drawHeaderCallback = (Rect rect) => {
            EditorGUI.LabelField(rect, "Anchors");
        };
    }