コード例 #1
0
 public void GenerateEdgeMesh(Action <Mesh> onGenerateMesh)
 {
     if (lastPaintIndex == -1)
     {
         Debug.LogError("lastPaintIndex == -1");
         return;
     }
     SafetyAreaEightNeighbourHelper.EightNeighbours(lastPaintIndex, (index) =>
     {
         return(colors[index] == Color.red);
     }, (edgeIndices) =>
     {
         float planeHeight = groundHeightStep.GetPlaneHeight();
         Mesh edgeMesh     = SafetyAreaVertexHelper.GenerateEdgeMesh(mesh, edgeIndices, planeHeight + 5f, planeHeight);
         onGenerateMesh?.Invoke(edgeMesh);
     });
 }
コード例 #2
0
    public void Init()
    {
        if (groundHeightStep == null)
        {
            groundHeightStep = SafetyAreaManager.Instance.GetStep <GroundHeightStep>(SafetyAreaStepEnum.GroundHeight);
        }

        MeshFilter meshFilter = this.gameObject.AddComponent <MeshFilter>();

        meshFilter.mesh = SafetyAreaVertexHelper.GeneratePlaneMesh();
        mesh            = meshFilter.mesh;
        MeshRenderer meshRenderer = this.gameObject.AddComponent <MeshRenderer>();

        meshRenderer.material = Resources.Load <Material>("Material/SafetyPlaneMat");
        MeshCollider meshCollider = this.gameObject.AddComponent <MeshCollider>();

        meshCollider.sharedMesh = mesh;
        ClearMeshColor();
    }
コード例 #3
0
    public void FillNearest(PointerEventData pointerEventData)
    {
        if (currentPointerEventData == null)
        {
            Debug.LogError("currentPointerEventData == null");
            return;
        }

        Vector3    raycastPosition      = pointerEventData.pointerCurrentRaycast.worldPosition;
        Vector3    pointerLocalPosition = transform.InverseTransformPoint(raycastPosition);
        List <int> effectIndices        = SafetyAreaVertexHelper.CaculateEffectVerticeIndices(pointerLocalPosition);

        for (int i = 0; i < effectIndices.Count; i++)
        {
            int index = effectIndices[i];
            colors[index]  = Color.red;
            lastPaintIndex = index;
        }
        mesh.colors = colors;
    }
コード例 #4
0
ファイル: StationaryAreaMono.cs プロジェクト: Skodeva/SDK4
    void Start()
    {
        if (stationaryAreaStep == null)
        {
            stationaryAreaStep = SafetyAreaManager.Instance.GetStep <StationaryAreaStep>(SafetyAreaStepEnum.StationaryArea);
        }

        if (groundHeightStep == null)
        {
            groundHeightStep = SafetyAreaManager.Instance.GetStep <GroundHeightStep>(SafetyAreaStepEnum.GroundHeight);
        }

        if (headTransform == null)
        {
            headTransform = SvrManager.Instance.head;
        }

        float      groundHeight = groundHeightStep.GetPlaneHeight();
        MeshFilter meshFilter   = this.gameObject.AddComponent <MeshFilter>();

        meshRenderer          = this.gameObject.AddComponent <MeshRenderer>();
        meshRenderer.material = Resources.Load <Material>("Material/SafetyEdgeMat");
        meshFilter.mesh       = SafetyAreaVertexHelper.GenerateCylinderMesh(new Vector3(0, groundHeight, 0), groundHeight + 5, groundHeight);
    }