public static string GetDateTime()
{
DateTime NowDate = DateTime.Now;
return NowDate.ToString("yyyy-MM-dd HH:mm:ss") + ":" + NowDate.Millisecond.ToString("000");
}
public static void func_Log(String msg)
{
string FilePath = Directory.GetCurrentDirectory() + @"\Logs\" + DateTime.Today.ToString("yyyyMMdd") + ".log";
string DirPath = Directory.GetCurrentDirectory() + @"\Logs";
string temp;
DirectoryInfo di = new DirectoryInfo(DirPath);
FileInfo fi = new FileInfo(FilePath);
try
{
if (di.Exists != true) Directory.CreateDirectory(DirPath);
if (fi.Exists != true)
{
using (StreamWriter sw = new StreamWriter(FilePath))
{
temp = string.Format("[{0}] {1}", GetDateTime(), msg);
sw.WriteLine(temp);
sw.Close();
}
}
else
{
using (StreamWriter sw = File.AppendText(FilePath))
{
temp = string.Format("[{0}] {1}", GetDateTime(), msg);
sw.WriteLine(temp);
sw.Close();
}
}
}
catch (Exception e)
{
Debug.Log("error :"+e.ToString());
}
}
2019년 5월 15일 수요일
두개의 다른 비율에 따른 거리 구하기
222222222222222222
reclamer 포지션 이동하는 로직
ex
0~ 710 이 비율에 맞게 x축 하는거
0 = -380
710 = 381
0~710 = 실제
0~761 = 시뮬
-380~381 = 시뮬
사실 시뮬이랑 실제랑 동일하게 맞추면 되지만
피치못할 사정으로 시뮬레이터를 변경하기 힘들어서(변경점이 너무 많아서 귀찮음)
해당하는 퍼센트만큼의 비율을 구해서
값을 변환해서 넣는다.
float Set_Reclaimer_Pos(int val)
{
if (710 < val || val < 0)
return -9999f;
float reslut = 0;
float realLenght = 710f;
int simulLenght = 761;
int offset = -380;
reslut = float.Parse (val.ToString()) / realLenght;
float convertVal;
convertVal = reslut * simulLenght + offset;
return convertVal;
}
reclamer 포지션 이동하는 로직
ex
0~ 710 이 비율에 맞게 x축 하는거
0 = -380
710 = 381
0~710 = 실제
0~761 = 시뮬
-380~381 = 시뮬
사실 시뮬이랑 실제랑 동일하게 맞추면 되지만
피치못할 사정으로 시뮬레이터를 변경하기 힘들어서(변경점이 너무 많아서 귀찮음)
해당하는 퍼센트만큼의 비율을 구해서
값을 변환해서 넣는다.
float Set_Reclaimer_Pos(int val)
{
if (710 < val || val < 0)
return -9999f;
float reslut = 0;
float realLenght = 710f;
int simulLenght = 761;
int offset = -380;
reslut = float.Parse (val.ToString()) / realLenght;
float convertVal;
convertVal = reslut * simulLenght + offset;
return convertVal;
}
현재 시간 값 초단위로 구하기
public static int GetNowTime()
{
System.DateTime now = System.DateTime.Now.ToLocalTime();
System.TimeSpan span = (now - new System.DateTime(1970, 1, 1, 0, 0, 0, 0).ToLocalTime() );
int nowTime = (int)span.TotalSeconds;
return nowTime;
}
2019년 5월 14일 화요일
mathf.pingpong 예제
PointLight1.GetComponent<Light>().intensity = Mathf.PingPong(Time.time * 120f, 100);
PointLight2.GetComponent<Light>().intensity = Mathf.PingPong(Time.time * 120f, 100);
LightBall_mat.SetFloat("_Metallic", Mathf.PingPong(Time.time, 1));
PointLight2.GetComponent<Light>().intensity = Mathf.PingPong(Time.time * 120f, 100);
LightBall_mat.SetFloat("_Metallic", Mathf.PingPong(Time.time, 1));
2019년 5월 13일 월요일
해당하는 이름이 포함되는 녀석 제거 재귀함수(fbxloader수정용)
//해당하는 이름이 포함되는 녀석 제거 재귀함수
IEnumerator func_Trash(Transform obj)
{
bool flage = true;
while (flage)
{
for (int i = 0; i < obj.childCount; i++)
{
if (obj.GetChild(i).name.Contains("$AssimpFbx$"))
{
List<Transform> changeParent = new List<Transform>();
for (int x = 0; x < obj.GetChild(i).childCount; x++)
{
changeParent.Add(obj.GetChild(i).GetChild(x).transform);
}
foreach (Transform ttt in changeParent)
{
ttt.parent = obj;
}
Destroy(obj.GetChild(i).gameObject);
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(i));
StartCoroutine(trash);
}
}
yield return new WaitForEndOfFrame();
if (obj.childCount == 0)
{
flage = false;
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(0));
StartCoroutine(trash);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TriLib.Samples;
using SimpleFileBrowser;
public class LoadFBX : MonoBehaviour {
public FileBrowser m_FileBrowser;
public AssetLoaderWindow m_AssetLoaderWindow;
public GameObject TEST;
// Use this for initialization
IEnumerator trash;
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("1"))
{
Debug.Log(" 1 ");
trash = func_Trash(TEST.transform);
StartCoroutine(trash);
}
}
public GameObject func_Load(string mPath)
{
//return m_AssetLoaderWindow.func_LoadInternal(mPath);//Path로 바로 불러오는 버전
Debug.Log("path :"+m_FileBrowser.func_GetPath());
return m_AssetLoaderWindow.func_LoadInternal(m_FileBrowser.func_GetPath());
}
public void func_Load_Button()
{
TEST = func_Load("sssss");
trash = func_Trash(TEST.transform);
StartCoroutine(trash);
}
//해당하는 이름이 포함되는 녀석 제거 재귀함수
IEnumerator func_Trash(Transform obj)
{
bool flage = true;
while (flage)
{
for (int i = 0; i < obj.childCount; i++)
{
if (obj.GetChild(i).name.Contains("$AssimpFbx$"))
{
List<Transform> changeParent = new List<Transform>();
for (int x = 0; x < obj.GetChild(i).childCount; x++)
{
changeParent.Add(obj.GetChild(i).GetChild(x).transform);
}
foreach (Transform ttt in changeParent)
{
ttt.parent = obj;
}
Destroy(obj.GetChild(i).gameObject);
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(i));
StartCoroutine(trash);
}
}
yield return new WaitForEndOfFrame();
if (obj.childCount == 0)
{
flage = false;
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(0));
StartCoroutine(trash);
}
}
}
}
IEnumerator func_Trash(Transform obj)
{
bool flage = true;
while (flage)
{
for (int i = 0; i < obj.childCount; i++)
{
if (obj.GetChild(i).name.Contains("$AssimpFbx$"))
{
List<Transform> changeParent = new List<Transform>();
for (int x = 0; x < obj.GetChild(i).childCount; x++)
{
changeParent.Add(obj.GetChild(i).GetChild(x).transform);
}
foreach (Transform ttt in changeParent)
{
ttt.parent = obj;
}
Destroy(obj.GetChild(i).gameObject);
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(i));
StartCoroutine(trash);
}
}
yield return new WaitForEndOfFrame();
if (obj.childCount == 0)
{
flage = false;
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(0));
StartCoroutine(trash);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using TriLib.Samples;
using SimpleFileBrowser;
public class LoadFBX : MonoBehaviour {
public FileBrowser m_FileBrowser;
public AssetLoaderWindow m_AssetLoaderWindow;
public GameObject TEST;
// Use this for initialization
IEnumerator trash;
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetKeyDown("1"))
{
Debug.Log(" 1 ");
trash = func_Trash(TEST.transform);
StartCoroutine(trash);
}
}
public GameObject func_Load(string mPath)
{
//return m_AssetLoaderWindow.func_LoadInternal(mPath);//Path로 바로 불러오는 버전
Debug.Log("path :"+m_FileBrowser.func_GetPath());
return m_AssetLoaderWindow.func_LoadInternal(m_FileBrowser.func_GetPath());
}
public void func_Load_Button()
{
TEST = func_Load("sssss");
trash = func_Trash(TEST.transform);
StartCoroutine(trash);
}
//해당하는 이름이 포함되는 녀석 제거 재귀함수
IEnumerator func_Trash(Transform obj)
{
bool flage = true;
while (flage)
{
for (int i = 0; i < obj.childCount; i++)
{
if (obj.GetChild(i).name.Contains("$AssimpFbx$"))
{
List<Transform> changeParent = new List<Transform>();
for (int x = 0; x < obj.GetChild(i).childCount; x++)
{
changeParent.Add(obj.GetChild(i).GetChild(x).transform);
}
foreach (Transform ttt in changeParent)
{
ttt.parent = obj;
}
Destroy(obj.GetChild(i).gameObject);
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(i));
StartCoroutine(trash);
}
}
yield return new WaitForEndOfFrame();
if (obj.childCount == 0)
{
flage = false;
}
else
{
StopCoroutine(trash);
trash = func_Trash(obj.GetChild(0));
StartCoroutine(trash);
}
}
}
}
2019년 5월 8일 수요일
자식 text객체의 크기에 맞춰 rectTransform Size 변경
자식 text객체의 크기에 맞춰 rectTransform Size 변경
자식 text객체에는 content size를 넣어줘서 크기 변경하게 하고
변경을 원하는 객체에 해당 스크립트를 적용시키면 됨
자식 text객체에는 content size를 넣어줘서 크기 변경하게 하고
변경을 원하는 객체에 해당 스크립트를 적용시키면 됨
1
2
3
4
5
6
7
8
9
|
if (this.gameObject.GetComponent<RectTransform>().sizeDelta.x != TargetText.preferredWidth)
{
this.gameObject.GetComponent<RectTransform>().sizeDelta = new Vector2(TargetText.preferredWidth, TargetText.preferredHeight);
Debug.Log("size변경");
}
| cs |
피드 구독하기:
글 (Atom)
git rejected error(feat. cherry-pick)
문제 아무 생각 없이 pull을 받지않고 로컬에서 작업! 커밋, 푸시 진행을 해버렷다. push에선 remote와 다르니 당연히 pull을 진행해라고 하지만 로컬에서 작업한 내용을 백업하지 않고 진행하기에는 부담스럽다(로컬작업 유실 가능성) 해결하려...
-
public class Test : MonoBehaviour { //매출 데이터를 읽어 들이고 Sales 객체 리스트를 반환한다. List<string> list = new List<string> { ...
-
1.람다식을 사용해 다음과 같은 코드를 작성합시다. var numbers = new List<int> { 12, 87, 94, 14, 53, 20, 40, 35, 76, 91, 31, 17, 48 }; 2.List<T>의 ...
-
legacy shader를 써야함 다른거는 변경해도 업데이트가 안됨