Ejemplo n.º 1
0
 public virtual void SceneUI()
 {
     Controls();
     if (m_BrushTex != null)
     {
         m_Brush = UBrush.Load(m_BrushTex, m_Brush);
         UBrush.PreviewBrush(m_Editor.terrain.gameObject, m_Brush, m_BrushSize);
     }
 }
Ejemplo n.º 2
0
 public static UBrush Load(Texture2D brushTex, UBrush brush)
 {
     if (brush == null)
     {
         brush = new UBrush();
     }
     brush.Load(brushTex, 64);
     return(brush);
 }
Ejemplo n.º 3
0
 Texture2D BrushField(Texture2D brushTex)
 {
     if (brushTex != null)
     {
         for (int i = 0, max = UIcon.brushes.Length; i < max; i++)
         {
             if (brushTex == UIcon.brushes[i])
             {
                 selectedBrush = i;
                 break;
             }
         }
     }
     selectedBrush = UBrush.IntFiled(selectedBrush);
     if (selectedBrush == -1)
     {
         return(null);
     }
     return(UIcon.brushes[selectedBrush]);
 }
Ejemplo n.º 4
0
        public static void PreviewBrushOfNormal(GameObject terrain, UBrush brush, float brushSize)
        {
            Vector3 normal = Vector3.zero;
            Vector3 hitPos = Vector3.zero;

            brush.enabled = true;

            Transform PPtransform = brush.projector.transform;
            bool      flag        = true;

            Vector2 newMousePostion = Event.current.mousePosition;

            newMousePostion.y = Screen.height - (Event.current.mousePosition.y + 35);
            Ray        ray = Camera.current.ScreenPointToRay(newMousePostion);
            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 50000f))
            {
                hitPos = hit.point;
                normal = hit.normal;
                if (hit.collider.gameObject != terrain)
                {
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }

            brush.enabled = flag;
            if (flag)
            {
                PPtransform.position = hitPos + (normal * 100);
                PPtransform.rotation = Quaternion.LookRotation(normal);
            }
            brush.projector.orthographicSize = brushSize;
        }
Ejemplo n.º 5
0
        public static void PreviewBrush(GameObject terrain, UBrush brush, float brushSize)
        {
            Vector3 hitPos = Vector3.zero;

            brush.enabled = true;
            float scaleSize = terrain.transform.lossyScale.x;

            Transform PPtransform = brush.projector.transform;
            bool      flag        = true;

            Vector2 newMousePostion = Event.current.mousePosition;

            newMousePostion.y = Screen.height - (Event.current.mousePosition.y + 35);
            Ray ray = SceneView.currentDrawingSceneView.camera.ScreenPointToRay(newMousePostion);

            RaycastHit hit;

            if (Physics.Raycast(ray, out hit, 50000f))
            {
                hitPos = hit.point;
                if (hit.collider.gameObject != terrain)
                {
                    flag = false;
                }
            }
            else
            {
                flag = false;
            }

            brush.enabled = flag;
            if (flag)
            {
                PPtransform.position = hitPos + Vector3.up * 100; //+ (normal * 100);
            }
            brush.projector.orthographicSize = brushSize * scaleSize;
        }