Ejemplo n.º 1
0
    private void ApplyMask()
    {
        if (m_RoadMask == null)
        {
            return;
        }
        m_IsPainterChanged = true;
        RenderTexture rt = RenderTexture.GetTemporary(m_RoadMask.width, m_RoadMask.height, 0);

        Graphics.Blit(m_RoadMask, rt);

        RenderTexture active = RenderTexture.active;

        RenderTexture.active = rt;
        Texture2D cont = new Texture2D(rt.width, rt.height);

        cont.ReadPixels(new Rect(0, 0, rt.width, rt.height), 0, 0);
        cont.Apply();
        RenderTexture.active = active;

        RenderTexture.ReleaseTemporary(rt);

        m_RoadMask = null;
        m_Target.SamplingFromTexture(cont);

        DestroyImmediate(cont);
        NavMeshEditorUtils.SetMaskTexture(null);
    }
Ejemplo n.º 2
0
    private void DrawTextureMappingGUI()
    {
        GUILayout.Label(styles.mappingSetting, styles.boldLabel);
        GUILayout.BeginVertical(styles.box);
        GUILayout.Label(styles.maskTexture, styles.boldLabel);

        EditorGUI.BeginChangeCheck();
        m_RoadMask = EditorGUILayout.ObjectField(styles.mask, m_RoadMask, typeof(Texture2D), false) as Texture2D;
        if (EditorGUI.EndChangeCheck())
        {
            NavMeshEditorUtils.SetMaskTexture(m_RoadMask);
        }

        //m_ApplyTextureMode = (TextureBlendMode) EditorGUILayout.EnumPopup(styles.blendMode, m_ApplyTextureMode);

        if (GUILayout.Button(styles.applyMask))
        {
            ApplyMask();
        }
        if (GUILayout.Button(styles.bake))
        {
            Bake();
        }
        if (GUILayout.Button(styles.clear))
        {
            Clear();
        }

        GUILayout.EndVertical();
    }
Ejemplo n.º 3
0
    void OnEnable()
    {
        m_Target = (NavMeshPainter)target;

        BuildData();

        List <Transform> transflist = new List <Transform>();

        for (int i = 0; i < m_Target.transform.childCount; i++)
        {
            var        child = m_Target.transform.GetChild(i);
            MeshFilter mf    = child.GetComponent <MeshFilter>();
            if (mf && mf.sharedMesh)
            {
                transflist.Add(child);
            }
            else
            {
                Object.DestroyImmediate(child.gameObject);
            }
        }
        m_Previews = transflist.ToArray();

        ResetCheckerBoard();
        NavMeshEditorUtils.SetMaskTexture(null);
    }
Ejemplo n.º 4
0
    void OnSceneGUI()
    {
        if (m_ShowCheckerBoard)
        {
            NavMeshEditorUtils.DrawCheckerBoard(m_Target.renderMeshs, Matrix4x4.identity);
        }

        switch (m_ToolType)
        {
        case ToolType.Erase:
        case ToolType.Paint:
            DrawPaintingToolSceneGUI();
            break;

        case ToolType.Mapping:
            DrawMappingSceneGUI();
            break;
        }
    }
Ejemplo n.º 5
0
    private void ResetCheckerBoard()
    {
        float minSize = m_Target.GetMinSize();

        NavMeshEditorUtils.SetCheckerBoardCellSize(minSize);
    }
Ejemplo n.º 6
0
 private void DrawMappingSceneGUI()
 {
     NavMeshEditorUtils.DrawMask(m_Target.renderMeshs, Matrix4x4.identity);
 }