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

카테고리

분류 전체보기 (2850)
Unity3D (893)
Script (94)
Extensions (16)
Effect (3)
NGUI (81)
UGUI (9)
Physics (2)
Shader (42)
Math (1)
Design Pattern (2)
Xml (1)
Tips (204)
Link (26)
World (1)
AssetBundle (25)
Mecanim (2)
Plugins (87)
Trouble Shooting (71)
Encrypt (7)
LightMap (4)
Shadow (4)
Editor (12)
Crash Report (3)
Utility (9)
UnityVS (2)
Facebook SDK (2)
iTween (3)
Font (18)
Ad (14)
Photon (2)
IAP (1)
Google (11)
URP (4)
Android (54)
iOS (46)
Programming (479)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (189)
협업 (64)
3DS Max (3)
Game (12)
Utility (142)
Etc (99)
Link (34)
Portfolio (19)
Subject (90)
iOS,OSX (52)
Android (16)
Linux (5)
잉여 프로젝트 (2)
게임이야기 (3)
Memories (20)
Interest (38)
Thinking (38)
한글 (30)
PaperCraft (5)
Animation (408)
Wallpaper (2)
재테크 (19)
Exercise (3)
나만의 맛집 (3)
냥이 (10)
육아 (16)
Total
Today
Yesterday
  1. using System.IO;
  2. DirectoryInfo dir = new DirectoryInfo(myPath);
  3. FileInfo[] info = dir.GetFiles("*.*");
  4. foreach (FileInfo f in info) 
  5. { ... }



참조 : http://msdn.microsoft.com/en-us/library/system.io.directoryinfo.aspx


출처 : http://answers.unity3d.com/questions/16433/get-list-of-all-files-in-a-directory.html

반응형
Posted by blueasa
, |

유니티엔진에서 일반적인 Timer()함수 대신에 MonoBehaviour 가 제공하는Invoke() 함수가 있습니다. 
Invoke(methodName:string, time:float) 
- methodName 메소드를 time 초 후 호출합니다. 

InvokeRepeating(methodName:string, time:float, repeatRate:float) 
- methodName 메소드를 time 초 후 호출합니다. 첫 호출 후 repeatRate 초 마다 반복 호출합니다. 
 InvokeRepeating 는 repeatRate 값이 0 보다 클때만 반복 호출됩니다. repeatRate 값이 0 일때는 최초 한번 호출 후 반복호출되지 않습니다.   ( 출처 : http://devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=50255#c_50287 )


CancelInvoke() 
- 이 스크립트에 있는 모든 Invoke 를 취소합니다. 

CancelInvoke(methodName:string) 
- 이 스크립트에 있는 methodName 을 호출하는 모든 Invoke 를 취소합니다. 



출처 : http://devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=31893&sca=&sfl=wr_subject%7C%7Cwr_content&stx=InvokeRepeating&sop=and&currentId=44



[참조]

http://blog.naver.com/bluefallsky/140190280479

http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.Invoke.html

http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.InvokeRepeating.html

http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.CancelInvoke.html

http://docs.unity3d.com/Documentation/ScriptReference/MonoBehaviour.IsInvoking.html

반응형
Posted by blueasa
, |




Link : http://www.richardfine.co.uk/2012/10/unity3d-monobehaviour-lifecycle/

반응형
Posted by blueasa
, |


http://answers.unity3d.com/questions/55512/Does-AssetBundle-on-Android-work-well-.html     : Android Asset Bundle

 

다음과 같이 에디터 오퍼레이션으로  Assetbundle 을 만드는데...

BuildPipeline 에서 무조건  플랫폼을 정해 줘야 한다.

 

 


//#if !UNITY_ANDROID

using UnityEngine;
using UnityEditor;
public class ExportAssetBundles { 
    [MenuItem("Assets/Build AssetBundle From Selection - Track dependencies")]  
    static void ExportResource () { 
        // Bring up save panel 
        string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d");
        if (path.Length != 0) {
            // Build the resource file from the active selection. 
            Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
            BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, BuildAssetBundleOptions.CollectDependencies | BuildAssetBundleOptions.CompleteAssets,BuildTarget.Android);   // 
            Selection.objects = selection;   
        } 
    } 
    [MenuItem("Assets/Build AssetBundle From Selection - No dependency tracking")] 
    static void ExportResourceNoTrack () {
        // Bring up save panel  
        string path = EditorUtility.SaveFilePanel ("Save Resource", "", "New Resource", "unity3d");
        if (path.Length != 0) { 
            // Build the resource file from the active selection. 
            BuildPipeline.BuildAssetBundle(Selection.activeObject, Selection.objects, path); 
        }  
    }
}
//#endif

 

 

 


        if (m_goPatchingScenePrefab.GetComponent<PatchingTesting>().m_nVersion < 2)
        {
            // Patching Update.......


           // WWW www = new WWW("http://192.168.0.40/ppp2.unity3d");

 

 

           WWW www =  WWW.LoadFromCacheOrDownload("http://192.168.0.40/ppp2.unity3d",2);
           

            //            www.uploadProgress

            /*while(!www.isDone)
            {


                        yield return 0;
            }
            */
            //  yeild retrun www.;


            yield return www;

 

 


            Debug.Log("Down Load Done!!");
            //    Instantiate(www.assetBundle.mainAsset);
            m_bDownloaded = true;
            //        Instantiate(www.assetBundle.mainAsset);

            //    www.assetBundle.LoadAll();


            m_goPatchingScenePrefab = (GameObject)www.assetBundle.Load("PatchingContests");

 

 

        }
       


            Instantiate(m_goPatchingScenePrefab);

 

 

 

 

IIS  설정 후....

 

1.  MIME 에 ~.unity3d를 추가 해야 한다.

2. crossdomain.xml 이 최 상위에 있어야 하는데...이건 만들어야 한다.

 

 

 

 

내용은...

 

인데....자세한 설명은

<?xml version="1.0"?>
<cross-domain-policy>
<allow-access-from domain="*"/>
</cross-domain-policy>
 

 

http://docs.unity3d.com/Documentation/Manual/SecuritySandbox.html

 

이곳에 있다.



[출처] Assetbundle 을 이용한 업데이트 시스템|작성자 timyman


반응형
Posted by blueasa
, |

Unity Singleton

Unity3D/Script / 2013. 3. 11. 10:58

Example :

GameMaster.cs

public class GameMaster : MonoSingleton< GameMaster >
{
    public int difficulty = 0;
    public override void Init(){ difficulty = 5; }
}

OtherClass.cs

You forgot a "using UnityEngine;" fixed. :P

using UnityEngine;
public class OtherClass: MonoBehaviour
{
    void Start(){ print( GameMaster.instance.difficulty ); } // 5
}

The code :

using UnityEngine;
public abstract class MonoSingleton<T> : MonoBehaviour where T : MonoSingleton<T>
{
    private static T m_Instance = null;
    public static T instance
    {
        get
        {
            // Instance requiered for the first time, we look for it
            if( m_Instance == null )
            {
                m_Instance = GameObject.FindObjectOfType(typeof(T)) as T;
 
                // Object not found, we create a temporary one
                if( m_Instance == null )
                {
                    Debug.LogWarning("No instance of " + typeof(T).ToString() + ", a temporary one is created.");
                    m_Instance = new GameObject("Temp Instance of " + typeof(T).ToString(), typeof(T)).GetComponent<T>();
 
                    // Problem during the creation, this should not happen
                    if( m_Instance == null )
                    {
                        Debug.LogError("Problem during the creation of " + typeof(T).ToString());
                    }
                }
                m_Instance.Init();
            }
            return m_Instance;
        }
    }
    // If no other monobehaviour request the instance in an awake function
    // executing before this one, no need to search the object.
    private void Awake()
    {
        if( m_Instance == null )
        {
            m_Instance = this as T;
            m_Instance.Init();
        }
    }
 
    // This function is called when the instance is used the first time
    // Put all the initializations you need here, as you would do in Awake
    public virtual void Init(){}
 
    // Make sure the instance isn't referenced anymore when the user quit, just in case.
    private void OnApplicationQuit()
    {
        m_Instance = null;
    }
}


출처 : http://wiki.unity3d.com/index.php/Singleton

반응형
Posted by blueasa
, |

NavMeshAgent.updatePosition = false;    // 포지션 업데이트 할 지..

NavMeshAgent.updateRotation = false;    // 로테이션 업데이트 할 지..


NavMesh를 쓰는 데, 파괴 가능한 오브젝트를 설치해야 되는데..


오브젝트와 충돌해서 지나가진 못하고, 파괴는 가능하게 하려니 오브젝트가 캐릭터에 의해 밀려다녀서 방법을 찾아보던 중..


NavMeshAngent에 포지션 업데이트 여부 셋팅 변수가 있다.


쓰자.. ㅡ_ㅡ;

반응형
Posted by blueasa
, |

  1. #pragma warning disable 0168 // variable declared but not used.
  2. #pragma warning disable 0219 // variable assigned but not used.
  3. #pragma warning disable 0414 // private field assigned but not used.


출처 : http://answers.unity3d.com/questions/21796/disable-warning-messages.html

반응형
Posted by blueasa
, |

1. 우선 새로 보여질 카메라를 하나 만든다.

2. 새 카메라의 Depth는 메인 카메라의 Depth보다 낮아야 된다.(같거나 높으면 메인 창에서도 새 카메라를 사용해버림)

3. 아래에서 m_strQuaterViewerName 은 카메라 오브젝트 이름이다. 임의로 집어넣게 만들어 놨음..

4. QuarterViewer.cs 스크립트는 Project 탭의 Editor 폴더 하위에 들어가야 한다.(에디트 시 사용될 스크립트라서..)


P.s. 예제에서는 RenderTextureFormat.ARGB32를 썼는데 Depth 문제가 있어서 RenderTextureFormat.Depth 로 고쳤다.


1 using UnityEngine; 2 using UnityEditor; 3 4 public class QuarterViewer : EditorWindow 5 { 6 private static EditorWindow editorWindow; 7 8 private string m_strQuaterViewerName; 9 private Camera m_camQuaterViewer; 10 private RenderTexture m_RenderTexture; 11 12 [MenuItem("Camera/Quarter Viewer")] 13 static void Init() 14 { 15 editorWindow = GetWindow(typeof(QuarterViewer)); 16 editorWindow.autoRepaintOnSceneChange = true; 17 editorWindow.Show(); 18 } 19 public void Awake() 20 { 21 m_RenderTexture = new RenderTexture((int)position.width, 22 (int)position.height, 23 (int)RenderTextureFormat.Depth); 24 25 m_strQuaterViewerName = "Camera - QuarterViewer"; 26 if (GameObject.Find(m_strQuaterViewerName)) 27 { 28 m_camQuaterViewer = GameObject.Find(m_strQuaterViewerName).GetComponent<Camera>(); 29 if (null == m_camQuaterViewer) 30 { 31 Debug.Log("Can't Find 'Camera - QuarterView'"); 32 } 33 } 34 } 35 public void Update() 36 { 37 if (null != m_camQuaterViewer && null != m_RenderTexture) 38 { 39 m_camQuaterViewer.targetTexture = m_RenderTexture; 40 m_camQuaterViewer.Render(); 41 m_camQuaterViewer.targetTexture = null; 42 43 if (m_RenderTexture.width != position.width || 44 m_RenderTexture.height != position.height) 45 { 46 m_RenderTexture = new RenderTexture((int)position.width, 47 (int)position.height, 48 (int)RenderTextureFormat.Depth); 49 } 50 } 51 } 52 void OnGUI() 53 { 54 if (null != m_camQuaterViewer && null != m_RenderTexture) 55 { 56 GUI.DrawTexture(new Rect(0.0f, 0.0f, position.width, position.height), m_RenderTexture); 57 } 58 59 } 60 }


[참조]

http://blueasa.tistory.com/943

http://docs.unity3d.com/Documentation/ScriptReference/EditorWindow-autoRepaintOnSceneChange.html

http://docs.unity3d.com/Documentation/ScriptReference/RenderTextureFormat.html


반응형
Posted by blueasa
, |

You can create a window in your gui with Gui.Windowhttp://unity3d.com/support/documentation/ScriptReference/GUI.Window.html?from=EditorWindow

Have the window you just made contain a RenderTexture.http://unity3d.com/support/documentation/Components/class-RenderTexture.html


http://unity3d.com/support/documentation/ScriptReference/EditorWindow-autoRepaintOnSceneChange




출처 : http://answers.unity3d.com/questions/33858/how-to-create-an-editor-screenview-like-camera-pre.html




반응형
Posted by blueasa
, |

1 if(Input.GetAxis("Mouse ScrollWheel") < 0) 2 { 3 // Zoom In 4 } 5 6 if(Input.GetAxis("Mouse ScrollWheel") > 0) 7 { 8 // Zoom Out 9 }




참조 : http://devkorea.co.kr/bbs/board.php?bo_table=m03_qna&wr_id=14508&sca=UNITY&sfl=wr_subject%7C%7Cwr_content&stx=%EB%A7%88%EC%9A%B0%EC%8A%A4+%ED%9C%A0&sop=and&currentId=44

반응형
Posted by blueasa
, |