블로그 이미지
Every unexpected event is a path to learning for you. blueasa

카테고리

분류 전체보기 (2795)
Unity3D (852)
Programming (478)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (185)
협업 (61)
3DS Max (3)
Game (12)
Utility (68)
Etc (98)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (55)
Android (14)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (18)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday



[Link] https://github.com/kimsama/Unity-NGUIExtension

반응형
Posted by blueasa
, |

[Link] 3DS Max ScriptSpot

3DS Max / 2016. 10. 10. 13:37


[Link] http://www.scriptspot.com/

반응형
Posted by blueasa
, |

Optimization Technique :

Let’s take an example, and see why and where we can optimise. Below  Coroutine just waits for the 0.5 sec and then call your desired method.

1
2
3
4
5
6
7
8
9
IEnumerator WaitCoroutine()
 
{
 
yield return new WaitForSeconds(0.5f);
 
// Call your Method here
 
}

 

But every time you call this method “new WaitForSeconds(0.5f)” will allocate memory for the new object, which is not good.

Instead, we should save its reference in Start, and use it when it is required, In this way, we will not allocate memory on every call.

01
02
03
04
05
06
07
08
09
10
11
12
13
14
15
WaitForSeconds wait;
 
void Start()
{
  wait = new WaitForSeconds(0.5f);
}
  
IEnumerator WaitCoroutine()
{
 
    yield return wait;
 
// Call your Method here
 
}

Never use “yield return 0“, instead of that use “yield return null



[출처] http://www.unitygeek.com/coroutines-in-unity3d/

반응형
Posted by blueasa
, |


[링크] http://lalawin.com/entry/jijinhee-noti

반응형
Posted by blueasa
, |

Max Script에서 한글 주석이 깨지는 문제가 보여서 UTF-8로 하면 될 줄 알았는데 안돼서 검색해보니 아래와 같은 내용이 있다.


설명대로 Default LanguageKorean으로 하니 한글이 제대로 잘 나온다.



[링크 내 리플 발췌]

firehouse님이 알려주신대로 메모장에서 utf-8로 변경했을때는 정상적으로 보이지만 맥스 스크립트를 한번 실행하면 다시 깨져 버리네요 -_-;;
자문 자답이 되어 버렸지만, 맥스 Preference Settings에 Files탭의 Default Language항목을 Korean으로 변경하니 깨짐이 없어졌습니다.
모두 수고 하세요.





[참조] http://cafe.daum.net/maxscript/76dv/1774

반응형
Posted by blueasa
, |

UNITY가 Play도중에 죽는 경우가 자주 발생하기 때문에 아래와 같이 Play를 감지하여 Assets을 저장하도록 하면 저장을 하지 못해서 편집한 내용이 유실되는 상황을 방지 할 수 있다.

using System.Collections;
using UnityEditor;
using UnityEngine;
 
[InitializeOnLoad]
public class SaveAssets
{
	static SaveAssets()
	{
		EditorApplication.playmodeStateChanged = () =>
		{
			if (EditorApplication.isPlayingOrWillChangePlaymode)
			{
				EditorApplication.SaveAssets();
			}
		};
	}
}
 



[출처]

http://www.antegg.com/wiki/doku.php?id=note:unity_3d:%EC%97%90%EB%94%94%ED%84%B0%EC%97%90%EC%84%9C_%EA%B2%8C%EC%9E%84_%ED%94%8C%EB%A0%88%EC%9D%B4%EB%A5%BC_%ED%95%A0_%EB%95%8C_%EC%A0%80%EC%9E%A5%EB%90%98%EC%A7%80_%EC%95%8A%EC%9D%80_assets_%EC%A0%80%EC%9E%A5%ED%95%98%EA%B8%B0


[참조]

https://docs.unity3d.com/ScriptReference/EditorApplication.SaveAssets.html

반응형
Posted by blueasa
, |

사이시옷은, 순우리말로 된 합성어나 순우리말과 한자어로 된 합성어에서, 앞말이 모음으로 끝나고, 뒷말의 첫소리가 된소리로 나거나 ‘ㄴ’ 또는 ‘ㄴㄴ’소리가 덧나는 경우와 두 음절로 된 한자어 중 ‘곳간(庫間), 셋방(貰房,) 숫자(數字), 찻간(車間), 툇간(退間), 횟수(回數)’에만 받치어 적습니다. 


‘최솟값, 최댓값’은 순우리말과 한자어로 된 합성어이고, 앞말이 모음으로 끝나며, 뒷말의 첫소리가 된소리로 나므로, 사이시옷을 받치어 적지만, ‘개수’는 위에서 언급한 사이시옷을 받치어 적는 환경에 해당하지 않으므로, ‘개수’로 적습니다.


(관련 규정: '한글 맞춤법' 제4장 제4절 제30항)




[출처] http://krdic.naver.com/rescript_detail.nhn?seq=6577

반응형

'한글' 카테고리의 다른 글

[펌] 자주 틀리는 우리말 맞춤법  (0) 2018.06.04
[펌] '구별하다'와 '구분하다'의 차이  (0) 2018.01.30
[펌] 고자질의 어원  (0) 2016.05.09
[펌] 궁색한 변명? 군색한 변명?  (0) 2016.05.09
자주 틀리는 맞춤법  (0) 2016.01.12
Posted by blueasa
, |

Apologies for the delay, I hit a brick wall dealing with WWW - as this is my first time I use this class, I didn't know that I had to provide the FULL path to a file for it to load it successfully.

The code is taken from here, with some modifications.

Just attach this to some gameObject, and have your music files in your Asset folder (at edit-time) or the game folder (when you build).

It's in C#, if you have trouble translating to JS let me know.

  1. using UnityEngine;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. public class MusicPlayer : MonoBehaviour
  7. {
  8. public enum SeekDirection { Forward, Backward }
  9. public AudioSource source;
  10. public List<AudioClip> clips = new List<AudioClip>();
  11. [SerializeField] [HideInInspector] private int currentIndex = 0;
  12. private FileInfo[] soundFiles;
  13. private List<string> validExtensions = new List<string> { ".ogg", ".wav" }; // Don't forget the "." i.e. "ogg" won't work - cause Path.GetExtension(filePath) will return .ext, not just ext.
  14. private string absolutePath = "./"; // relative path to where the app is running - change this to "./music" in your case
  15. void Start()
  16. {
  17. //being able to test in unity
  18. if (Application.isEditor) absolutePath = "Assets/";
  19. if (source == null) source = gameObject.AddComponent<AudioSource>();
  20. ReloadSounds();
  21. }
  22. void OnGUI()
  23. {
  24. if (GUILayout.Button("Previous")) {
  25. Seek(SeekDirection.Backward);
  26. PlayCurrent();
  27. }
  28. if (GUILayout.Button("Play current")) {
  29. PlayCurrent();
  30. }
  31. if (GUILayout.Button("Next")) {
  32. Seek(SeekDirection.Forward);
  33. PlayCurrent();
  34. }
  35. if (GUILayout.Button("Reload")) {
  36. ReloadSounds();
  37. }
  38. }
  39. void Seek(SeekDirection d)
  40. {
  41. if (d == SeekDirection.Forward)
  42. currentIndex = (currentIndex + 1) % clips.Count;
  43. else {
  44. currentIndex--;
  45. if (currentIndex < 0) currentIndex = clips.Count - 1;
  46. }
  47. }
  48. void PlayCurrent()
  49. {
  50. source.clip = clips[currentIndex];
  51. source.Play();
  52. }
  53. void ReloadSounds()
  54. {
  55. clips.Clear();
  56. // get all valid files
  57. var info = new DirectoryInfo(absolutePath);
  58. soundFiles = info.GetFiles()
  59. .Where(f => IsValidFileType(f.Name))
  60. .ToArray();
  61. // and load them
  62. foreach (var s in soundFiles)
  63. StartCoroutine(LoadFile(s.FullName));
  64. }
  65. bool IsValidFileType(string fileName)
  66. {
  67. return validExtensions.Contains(Path.GetExtension(fileName));
  68. // Alternatively, you could go fileName.SubString(fileName.LastIndexOf('.') + 1); that way you don't need the '.' when you add your extensions
  69. }
  70. IEnumerator LoadFile(string path)
  71. {
  72. WWW www = new WWW("file://" + path);
  73. print("loading " + path);
  74. AudioClip clip = www.GetAudioClip(false);
  75. while(!clip.isReadyToPlay)
  76. yield return www;
  77. print("done loading");
  78. clip.name = Path.GetFileName(path);
  79. clips.Add(clip);
  80. }
  81. }

Couple of notes:

  1. You might ask, why use create a DirectoryInfo and then call GetFiles on that, instead of just directly go Directory.GetFiles(path)? Well, the latter one will return the paths of the files in pathrelative to path and NOT the full path (which is what you'll need to pass into WWW). i.e. if you do Directory.GetFiles("Assets"); it will return, (for example) a string array of { "Assets/soundFile1.wav", "Assets/soundFile2.ogg", etc } - these paths are relative to "Assets" while the full path would be "E:\Dropbox\UnityStuff\MyProject...\soundFile.wav"

  2. MP3s won't work in a PC build (haven't tried wav, but it should work) see this for more info. If you want MP3s, you have to go for something more complex, like MP3Sharp,NAudio and others.

  3. If you want to search recursively, change your GetFiles() call to GetFiles("*.*", SearchOption.AllDirectories)

EDIT:

JS, as per your request

  1. import UnityEngine;
  2. import System.Collections.Generic;
  3. import System.IO;
  4. import System.Linq;
  5. public enum SeekDirection { Forward, Backward }
  6. public var source : AudioSource;
  7. public var clips : List.<AudioClip> = new List.<AudioClip>();
  8. @HideInInspector @SerializeField private var currentIndex : int = 0;
  9. private var soundFiles : FileInfo[];
  10. private var validExtensions : List.<String> = new List.<String> ([ ".ogg", ".wav" ]);
  11. private var absolutePath : String = "./"; // relative path to where the app is running
  12. function Start()
  13. {
  14. //being able to test in unity
  15. if (Application.isEditor)
  16. absolutePath = "Assets/";
  17. if (source == null)
  18. source = gameObject.AddComponent.<AudioSource>();
  19. ReloadSounds();
  20. }
  21. function OnGUI()
  22. {
  23. if (GUILayout.Button("Previous")) {
  24. Seek(SeekDirection.Backward);
  25. PlayCurrent();
  26. }
  27. if (GUILayout.Button("Play current")) {
  28. PlayCurrent();
  29. }
  30. if (GUILayout.Button("Next")) {
  31. Seek(SeekDirection.Forward);
  32. PlayCurrent();
  33. }
  34. if (GUILayout.Button("Reload")) {
  35. ReloadSounds();
  36. }
  37. }
  38. function Seek(d : SeekDirection)
  39. {
  40. if (d == SeekDirection.Forward)
  41. currentIndex = (currentIndex + 1) % clips.Count;
  42. else {
  43. currentIndex--;
  44. if (currentIndex < 0) currentIndex = clips.Count - 1;
  45. }
  46. }
  47. function PlayCurrent()
  48. {
  49. source.clip = clips[currentIndex];
  50. source.Play();
  51. }
  52. function ReloadSounds()
  53. {
  54. clips.Clear();
  55. // get all valid files
  56. var info = new DirectoryInfo(absolutePath);
  57. soundFiles = info.GetFiles()
  58. .Where(function (f) { return IsValidFileType(f.Name); } )
  59. .ToArray();
  60. // and load them
  61. for(var s in soundFiles)
  62. StartCoroutine(LoadFile(s.FullName));
  63. }
  64. function IsValidFileType(fileName : String) : boolean
  65. {
  66. return validExtensions.Contains(Path.GetExtension(fileName));
  67. }
  68. function LoadFile(path : String)
  69. {
  70. var www = new WWW("file://" + path);
  71. print("loading " + path);
  72. var clip = www.GetAudioClip(false);
  73. while(!clip.isReadyToPlay)
  74. yield www;
  75. print("done loading");
  76. clip.name = Path.GetFileName(path);
  77. clips.Add(clip);
  78. }




[출처] http://answers.unity3d.com/questions/652919/music-player-get-songs-from-directory.html

반응형
Posted by blueasa
, |
Hey guys,

Just wanted to post a snippet in case it turns out to be helpful for anyone using an alternate localization solution with NGUI.

I'm currently using Smart Localization which can be found here: http://forum.unity3d.com/threads/173837-RELEASED-Smart-Localization-for-Unity3D

It's really good, it's free and has some neat features such as Microsoft Translate integration.

In order to use it with NGUI, simply type your string key into the label field and drag this script on.

Cheers!

Code (csharp):
  1.  
  2. using UnityEngine;
  3. using System.Collections;
  4. using System.Globalization;
  5.  
  6. [RequireComponent(typeof(UIWidget))]
  7. [AddComponentMenu("NGUI/UI/LocalizeWidget")]
  8. public class LocalizeWidget : MonoBehaviour
  9. {
  10.     // No public variables, we'll get the key from the widget field
  11.     private string key;
  12.     private string mLanguage;
  13.     private LanguageManager loc;
  14.  
  15.     // Localize the widget on start.
  16.     private void Start()
  17.     {
  18.         // Reference the language manager
  19.         loc = LanguageManager.Instance;
  20.        
  21.         // Hook up a delegate to run the localize script whenever a language was changed
  22.         loc.OnChangeLanguage += new ChangeLanguageEventHandler(Localize);
  23.        
  24.         // Initial localize run
  25.         Localize();
  26.     }
  27.    
  28.     // Incase the script didn't get the message from being inactive
  29.     private void OnEnable()
  30.     {
  31.         if(mLanguage != loc.language)
  32.             Localize();
  33.     }
  34.    
  35.     // Force-localize the widget.
  36.     private void Localize(LanguageManager thisLanguage=null)
  37.     {
  38.         UIWidget w = GetComponent<UIWidget>();
  39.         UILabel lbl = w as UILabel;
  40.         UISprite sp = w as UISprite;
  41.  
  42.         // If no localization key has been specified, use the label's text as the key
  43.         if (lbl != null)
  44.             key = lbl.text;
  45.        
  46.         string val = loc.GetTextValue(key);
  47.        
  48.         if(string.IsNullOrEmpty(val))
  49.             val = "Missing String";
  50.  
  51.         if (lbl != null)
  52.         {
  53.             // If this is a label used by input, we should localize its default value instead
  54.             UIInput input = NGUITools.FindInParents<UIInput>(lbl.gameObject);
  55.            
  56.             if (input != null  input.label == lbl)
  57.                 input.defaultText = val;
  58.             else
  59.                 lbl.text = val;
  60.         }
  61.         else if (sp != null)
  62.         {
  63.             sp.spriteName = val;
  64.             sp.MakePixelPerfect();
  65.         }
  66.        
  67.         // Set this widget's current language
  68.         mLanguage = loc.language;
  69.     }
  70. }
  71.  
 



출처 : http://forum.unity3d.com/threads/smart-localization-with-ngui.189253/


참조 : http://forum.unity3d.com/threads/released-smart-localization-for-unity3d.173837/

반응형
Posted by blueasa
, |

Unity로 안드로이드 앱을 개발하다보면 스크롤 안에 버튼이 들어갈 경우가 종종 있다.

PC에서 테스트 할 때는 마우스로 잘 눌리던 버튼이 스마트 폰에 넣어서 테스트 해보면 간혹 잘 눌리지 않는 경우가 있다. 이럴때 EventSystem 설정을 바꿔줘야하는데 다음과 같이 세팅 하면 적당하다.



10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
private const float inchToCm = 2.54f;
     
[SerializeField]
private EventSystem eventSystem = null;
     
[SerializeField]
private float dragThresholdCM = 0.5f;
//For drag Threshold
     
private void SetDragThreshold()
{
    if (eventSystem != null)
    {
        eventSystem.pixelDragThreshold = (int)(dragThresholdCM * Screen.dpi / inchToCm);
    }
}
  
  
void Awake()
{
    SetDragThreshold();
}



출처 : http://knightk.tistory.com/12

반응형
Posted by blueasa
, |