2022년 6월 27일 월요일

unity WebGL 빌드시 유의사항

 경로에 한글 _ 띄워쓰기 등 이상한게 끼어있으면 빌드 에러가 난다.

clang++.exe 를 에서 에러가남


프로젝트 경로 뿐만아니라


hierarchy에서의 게임오브젝트 이름에서도 해당 규칙을 지켜줘야한다...



Exception: Unity.IL2CPP.Building.BuilderFailedException: clang++.exe: error: unable to execute command: Couldn't execute program 'C:\Program Files\Unity\Hub\Editor\2020.3.30f1\Editor\Data\PlaybackEngines\WebGLSupport\BuildTools\Emscripten_FastComp_Win\clang++.exe': �׼����� �źεǾ����ϴ�.  (0x5)
ERROR:root:compiler frontend failed to generate LLVM bitcode, halting





2022년 6월 19일 일요일

[ironpython] pip install pandas

 ironpython은 pip install 같은걸로 패키지설치 불가능


var paths = engine.GetSearchPaths();
paths.Add(@"C:\Users\anaconda3\envs\py37_32");
paths.Add(@"C:\Users\anaconda3\envs\py37_32\DLLs");
paths.Add(@"C:\Users\anaconda3\envs\py37_32\Lib");
paths.Add(@"C:\Users\anaconda3\envs\py37_32\Lib\site-packages");
engine.SetSearchPaths(paths);

이런식으로 원하는 package가 설치되어있는 anaconda 환경을 통째로

들고오면 c#에서도 python 사용이 가능하다!!!


2022년 6월 9일 목요일

python list

 



### 작은순서로 sorting하고 앞에 4개만 남기는 리스트
        d1 = sorted(Dict_distance.items(),key=operator.itemgetter(1),reverse=False)[:4]
        print(d1)

2022년 6월 8일 수요일

Unity TextBubble(말풍선)

 





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


using UnityEngine.UI;

public class TextBubble : MonoBehaviour
{

    public TextMeshProUGUI target;
    public string[] value;

   

    public HorizontalLayoutGroup textGroup;
    public GameObject TextImage;
    bool isOn;

    IEnumerator ActiveBubble;
    // Start is called before the first frame update
    void Start()
    {
        StartCoroutine(AutoStart());
       
    }

    IEnumerator AutoStart()
    {
        value = new string[3];

        value[0] = "(주)테스크는 2006년 1월 차량용 \n " +
                    "배기계 부품 전문 제조기업인 \n" +
                    "(주)정도정밀 에서 분사하여 \n" +
                    "고객에게 새로운 가치를 \n" +
                    " 제공하고  환경 친화적 \n" +
                    "자동차 부품 개발에 집중하고 있습니다. \n";



        value[1] = "새롭게 설립된 회사로 그간 \n" +
                    "끊임없는 연구개발 투자와 \n" +
                    "신기술 도입을 통해 차량용 \n" +
                    "배기계 부품의 개발 및 제조 전문기업으로 \n" +
                    "확고한 위상을 구축하고 있습니다.";

        value[2] = "진정한 글로벌 경쟁력을 갖추고 \n" +
                    "무한 성장할 수 있는 발판을 \n" +
                    "확고히 다져나가고 있습니다.";

        isOn = true;

        yield return new WaitForSeconds(2f);

        ActiveTextBubble();
        textGroup.padding = new RectOffset(1, 1, 0, 1);
    }


    void OnMouseDown()
    {
        if (TextImage.activeSelf)
        {
            TextImage.SetActive(false);
            return;
        }

        if (!TextImage.activeSelf)
        {
            TextImage.SetActive(true);
            return;
        }

        if (!isOn)
            return;
    }


    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("1"))
        {
            ActiveTextBubble();
        }
    }


    void ActiveTextBubble()
    {
        isOn = false;
        target.text = "";
        if (ActiveBubble != null)
        {
            StopCoroutine(ActiveBubble);
            ActiveBubble = null;
        }
        ActiveBubble = CreateTextBubble();
        StartCoroutine(ActiveBubble);
    }


    IEnumerator CreateTextBubble()
    {

        foreach (var x in value)
        {
            target.text = "";
            for (int i = 0; i < x.Length; i++)
            {
                target.text += x[i];
                yield return new WaitForSeconds(0.05f);
            }
            yield return new WaitForSeconds(1.5f);
        }

       
    }
}





Unity PlayerMouseLook

 



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

public class PlayerMouseLook : MonoBehaviour
{
    public float mouseSensitivity = 1000f;

    public Transform playerBody;
   
    float xRotation = 0f;

    public GameObject checker;

    bool clicked;
    // Start is called before the first frame update
    void Start()
    {
        //Cursor.lockState = CursorLockMode.Locked;
    }

    // Update is called once per frame
    void Update()
    {

        if (Input.GetKey(KeyCode.LeftAlt))
        {

            if (Input.GetMouseButtonDown(0))
            {
                clicked = true;
            }
            if (!clicked)
            {
                checker.SetActive(true);
                SetCheckerPosition();
            }

        }
        else
        {
            clicked = false;
            checker.SetActive(false);
            LookRotation();
        }




    }

    void LookRotation()
    {
        float mouseX = Input.GetAxis("Mouse X") * mouseSensitivity * Time.deltaTime;
        float mouseY = Input.GetAxis("Mouse Y") * mouseSensitivity * Time.deltaTime;

        xRotation -= mouseY;
        xRotation = Mathf.Clamp(xRotation, -90f, 90f);


        transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f);
        playerBody.Rotate(Vector3.up * mouseX);
    }

    void SetCheckerPosition()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit raycastHit))
        {
            checker.transform.position = raycastHit.point;
        }
    }

   
}






Unity PlayerMovement

 




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

public class PlayerMovement : MonoBehaviour
{
    public CharacterController controller;
    public NavMeshAgent playerNavMeshAgent;


    public float speed = 12f;
    public float gravity = -9.81f;
    public float jumpHeight = 3f;

    public Transform groundCheck;
    public float groundDistance = 0.4f;
    public LayerMask groundMask;


    public Vector3 clickPos;

    Vector3 velocity;
    bool isGrounded;

    public bool isClicked;

   

    // Update is called once per frame
    void Update()
    {


        if (Input.GetKey(KeyCode.LeftAlt))
        {
            playerNavMeshAgent.enabled = true;
            controller.enabled = false;
            if (Input.GetMouseButtonDown(0))
            {
                MoveClickPosition();
            }
        }

        gravityMove();



        if (isClicked)
        {
           
        }
        else
        {
            NormalMove();
        }

        if (Input.GetAxis("Horizontal") != 0 || Input.GetAxis("Vertical") != 0)
        {
            playerNavMeshAgent.enabled = false;
            controller.enabled = true;
            isClicked = false;
        }
        //if (Input.anyKeyDown)
        //{
        //    if (isClicked)
        //        isClicked = false;
        //}
    }


    void NormalMove()
    {
        float x = Input.GetAxis("Horizontal");
        float z = Input.GetAxis("Vertical");

        Vector3 move = transform.right * x + transform.forward * z;

        controller.Move(move * speed * Time.deltaTime);
       
    }

    void gravityMove()
    {
        if (Input.GetButtonDown("Jump") && isGrounded)
        {
            velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity);
        }
        isGrounded = Physics.CheckSphere(groundCheck.position, groundDistance, groundMask);

        if (isGrounded && velocity.y < 0)
        {
            velocity.y = -2f;
        }
        velocity.y += gravity * Time.deltaTime;
        controller.Move(velocity * Time.deltaTime);
    }



    void MoveClickPosition()
    {
        isClicked = true;
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        if (Physics.Raycast(ray, out RaycastHit raycastHit))
        {
            playerNavMeshAgent.SetDestination(raycastHit.point);
        }
    }
}





Unity UpDown Plusing

 



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

public class UpDownMove : MonoBehaviour
{

    Transform TargetObject;
    float plusSize = 0.015f;
    float tempo = 0.025f;

    private bool coroutineAllowed;
    // Start is called before the first frame update

    private void Start()
    {
        TargetObject = transform;
        coroutineAllowed = true;
    }
    // Update is called once per frame
    void Update()
    {
        if (coroutineAllowed)
        {
            StartCoroutine(StartPlusing());
        }
    }

    private IEnumerator StartPlusing()
    {
        coroutineAllowed = false;


        for (float i = 0f; i < 1f; i += 0.1f)
        {
            transform.localScale = new Vector3(
                (Mathf.Lerp(TargetObject.localScale.x, TargetObject.localScale.x , Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.y, TargetObject.localScale.y + plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.z, TargetObject.localScale.z + plusSize * 0.1f, Mathf.SmoothStep(0f, 1f, i)))

                );
            yield return new WaitForSeconds(tempo);
        }


        for (float i = 0f; i < 1f; i += 0.1f)
        {
            transform.localScale = new Vector3(
                (Mathf.Lerp(TargetObject.localScale.x, TargetObject.localScale.x , Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.y, TargetObject.localScale.y - plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.z, TargetObject.localScale.z - plusSize*0.1f, Mathf.SmoothStep(0f, 1f, i)))
                );
            yield return new WaitForSeconds(tempo);
        }

        coroutineAllowed = true;
    }
}






Unity Plusing Object(움찔움찔하는기능)

 

포인트 같은거 자동으로 움직이게 하는 코드


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

public class Plusing : MonoBehaviour
{

    public Transform TargetObject;
    public float plusSize = 0.025f;
    private bool coroutineAllowed;
    // Start is called before the first frame update
    void Start()
    {
        TargetObject = transform;
        coroutineAllowed = true;
    }

    void OnMouseOver()
    {
        if (coroutineAllowed)
        {
            StartCoroutine(StartPlusing());
        }
    }

    private IEnumerator StartPlusing()
    {
        coroutineAllowed = false;


        for (float i = 0f; i < 1f; i += 0.1f)
        {
            transform.localScale = new Vector3(
                (Mathf.Lerp(TargetObject.localScale.x, TargetObject.localScale.x + plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.y, TargetObject.localScale.y + plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.z, TargetObject.localScale.z + plusSize, Mathf.SmoothStep(0f, 1f, i)))

                );
            yield return new WaitForSeconds(0.015f);
        }


        for (float i = 0f; i < 1f; i += 0.1f)
        {
            transform.localScale = new Vector3(
                (Mathf.Lerp(TargetObject.localScale.x, TargetObject.localScale.x - plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.y, TargetObject.localScale.y - plusSize, Mathf.SmoothStep(0f, 1f, i))),
                (Mathf.Lerp(TargetObject.localScale.z, TargetObject.localScale.z - plusSize, Mathf.SmoothStep(0f, 1f, i)))
                );
            yield return new WaitForSeconds(0.015f);
        }

        coroutineAllowed = true;
    }

}




unity move smooth

 


unity 

타겟지점까지 움직이고(smooth)

lookat을 처다보기



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

public class VideoClick : MonoBehaviour
{
    // Start is called before the first frame update

   
    public Camera ActiveVideoCam;

   
    public GameObject TargetPos;
    public GameObject LookAtPoint;


    PlayerMouseLook PlayLook;
    public Vector3 InitPos;

    public GameObject[] UnActiveGameObjects;


    public float moveSpeed = 1;
    private Vector3 velocity = Vector3.zero;
    IEnumerator moveCam;


    private void Start()
    {
        PlayLook = FindObjectOfType<PlayerMouseLook>();
    }

    // Update is called once per frame
    void Update()
    {
        if (Input.GetKeyDown("1"))
        {
            ZoomIn();
        }

        if (Input.GetKeyDown("2"))
        {
            Out();
        }
    }


    public void ZoomIn()
    {

        foreach (var x in UnActiveGameObjects)
        {
            x.SetActive(false);
        }

        PlayLook.enabled = false;
        if (moveCam != null)
        {
            StopCoroutine(moveCam);
            moveCam = null;
        }
        moveCam = SetZoomIn();
        StartCoroutine(moveCam);

    }

    public void Out()
    {

        foreach (var x in UnActiveGameObjects)
        {
            x.SetActive(true);
        }

        PlayLook.enabled = true;
        if (moveCam != null)
        {
            StopCoroutine(moveCam);
            moveCam = null;
        }
        ActiveVideoCam.transform.position = InitPos;
    }

    IEnumerator SetZoomIn()
    {

       
        InitPos = ActiveVideoCam.transform.position;

       
       
       
        //Vector3 originPosition = ActiveVideoCam.transform.position;
        Vector3 target = TargetPos.transform.position;

        while (true)
        {
            ActiveVideoCam.transform.position = Vector3.SmoothDamp(ActiveVideoCam.transform.position, target, ref velocity, moveSpeed);
            ActiveVideoCam.transform.LookAt(LookAtPoint.transform.position);

            if (Mathf.Abs(ActiveVideoCam.transform.position.x - target.x) < 0.1f)
                break;

            yield return new WaitForEndOfFrame();
        }
       
    }

}

git rejected error(feat. cherry-pick)

 문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...