//출처 : https://forum.unity.com/threads/drawfrustum-is-drawing-incorrectly.208081/

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CameraFrustumDrawer : MonoBehaviour
{
    [SerializeField] private Camera cam;

    private void OnDrawGizmos()
    {
        DrawFrustum(cam);
    }

    private void DrawFrustum(Camera _cam)
    {
        if (null == _cam)
        {
            return;
        }

        Vector3[] nearCorners = new Vector3[4]; //Approx'd nearplane corners
        Vector3[] farCorners = new Vector3[4]; //Approx'd farplane corners
        Plane[] camPlanes = GeometryUtility.CalculateFrustumPlanes(_cam); //get planes from matrix
        Plane temp = camPlanes[1]; camPlanes[1] = camPlanes[2]; camPlanes[2] = temp; //swap [1] and [2] so the order is better for the loop

        for (int i = 0; i < 4; i++)
        {
            nearCorners[i] = Plane3Intersect(camPlanes[4], camPlanes[i], camPlanes[(i + 1) % 4]); //near corners on the created projection matrix
            farCorners[i] = Plane3Intersect(camPlanes[5], camPlanes[i], camPlanes[(i + 1) % 4]); //far corners on the created projection matrix
        }

        for (int i = 0; i < 4; i++)
        {
            Debug.DrawLine(nearCorners[i], nearCorners[(i + 1) % 4], Color.red, Time.deltaTime, true); //near corners on the created projection matrix
            Debug.DrawLine(farCorners[i], farCorners[(i + 1) % 4], Color.blue, Time.deltaTime, true); //far corners on the created projection matrix
            Debug.DrawLine(nearCorners[i], farCorners[i], Color.green, Time.deltaTime, true); //sides of the created projection matrix
        }
    }

    Vector3 Plane3Intersect(Plane p1, Plane p2, Plane p3)
    {
        //get the intersection point of 3 planes
        return ((-p1.distance * Vector3.Cross(p2.normal, p3.normal)) +
                (-p2.distance * Vector3.Cross(p3.normal, p1.normal)) +
                (-p3.distance * Vector3.Cross(p1.normal, p2.normal))) /
                (Vector3.Dot(p1.normal, Vector3.Cross(p2.normal, p3.normal)));
    }
}


출처: https://forum.unity.com/threads/drawfrustum-is-drawing-incorrectly.208081/

tmp에 date 결과값 저장

tmp=$(date +%Y.%m.%d_%H:%M:%S)


echo를 이용한 응용도 가능함
현재 파일리스트 생성

rm file_list
echo $(ls -1) >> file_list

Error Log

Execution failed for task ':launcher:minifyReleaseWithProguard'.
> java.io.IOException: Can't read [C:\Unity\2020.3.48f1\Editor\Data\PlaybackEngines\AndroidPlayer\SDK\platforms\android-33\optional\android.car.jar] (Can't process class [android/car/Car$CarServiceLifecycleListener.class] (Unsupported version number [55.0] (maximum 54.0, Java 10)))

유니티 버전: 2020.3.48f1
상황: API버전을 31에서 33으로 변경
원인: API33에서 Proguard가 정상 동작하지 않음
해법: R8을 사용해야함

1. Custom Gradle Proerties Template 활성화
위치: Project Setting -> Player -> Android -> Publishing Settings -> Build-> Custom Gradle Proerties Template
2. Assets\Plugins\Android\gradleTemplate.properties 에서 android.enableR8을 true로 변경

Custom Gradle Proerties Template 위치




'Unity' 카테고리의 다른 글

[Unity] 카메라 절두체 그리기(Frustum of a camera in Unity)  (0) 2024.02.21

+ Recent posts