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

카테고리

분류 전체보기 (2737)
Unity3D (817)
Programming (474)
Server (33)
Unreal (4)
Gamebryo (56)
Tip & Tech (228)
협업 (58)
3DS Max (3)
Game (12)
Utility (136)
Etc (96)
Link (32)
Portfolio (19)
Subject (90)
iOS,OSX (53)
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
04-24 00:01

'find'에 해당되는 글 2건

  1. 2021.11.26 [펌] Find objects with DontDestroyOnLoad
  2. 2011.11.20 TreeView에서 Find 함수 사용 방법

The saved objects are handled on the native side, and there is no way I know of to hook into that side of Unity.


As an aside, here's an example of using an extension to track such a quality:

I would create a an extension for Object which stores all saved objects, something like this:

  1. public static class ObjectExtension {
  2.  
  3. private static List<Object> savedObjects = new List<Object>();
  4.  
  5. public static void DontDestroyOnLoad(this Object obj){
  6. savedObjects.Add(obj);
  7. Object.DontDestroyOnLoad(obj);
  8. }
  9.  
  10. public static void Destory(this Object obj){
  11. savedObjects.Remove(obj);
  12. Destory(obj);
  13. }
  14.  
  15. public static List<Objects> GetSavedObjects(){
  16. return new List<Objects>(savedObjects);
  17. }
  18. }
  19.  

Now, to save the object you'll have to use this.DontDestroyOnLoad(); instead of the normal DontDestroyOnLoad(this);

EDIT:

I started looking into this and found that setting a GameObject's hideflags to HideFlags.DontSave means (as far as I can tell) the same thing as DontDestroyOnLoad, except that none of Unity's functions (Update, etc.) are called. The one with hideflags might also leak if not destroyed manually...

Finding GameObjects with its hideFlags set to DontSave is trivial.

 

 

 

[출처] https://answers.unity.com/questions/544886/find-objects-with-dontdestroyonload.html

 

Find objects with DontDestroyOnLoad - Unity Answers

 

answers.unity.com

 

반응형
Posted by blueasa
, |

[참조]


위에 보면 Find 함수를 쓴다.
[예: treeNode.Nodes.Find(string key, bool searchAllChildren)]

그런데 직접 만들고 써보니 찾지를 못한다..
[처음 삽질한 방법]
TreeNode.Nodes.Add("AAA");
TreeNode[] arrayTN = TreeNode.Nodes.Find("AAA", false);

뭘까..하고 이리저리 찾아보다보니..

TreeNode.Nodes.Add() 함수는 몇가지 오버로딩 함수를 가지는 데,

그 중,
1) TreeNode.Nodes.Add(string text);
2) TreeNode.Nodes.Add(string key, string text); 
두가지 함수의 차이에 대해 알아야 될 것 같다.

첫 삽질에서 사용 한 함수는 1) 함수이다.

그런데 Find 함수의 첫 인자인 key는 Node의 Name이라고 위 참조글에 적혀 있다.
TreeNode.Nodes.Add("AAA"); 는 1) 함수에 보면 key(Name)가 아니라 text이다.
 그래서 Name엔 기본값인 빈 문장("")이 들어가 있다.
결과적으로 Find로 찾는 Name값은 빈문장이기 때문에 "AAA"를 찾을 수 없다.

Find를 쓰려면 Node를 Add할 때 2) 함수로 추가를 해줘야 한다.
어차피 Text와 Name이 다를 필요가 없을 것 같아서 같게 해줬다.

[해결방법]
TreeNode.Nodes.Add("AAA", "AAA");
TreeNode.Nodes.Find("AAA", false);

P.s. Find 후 TreeNode[] 변수가  반환 되는데, 찾은 노드의 개수 판단은 Count가 아니라 Length 프로퍼티이다.
      (
Length가 0이면 찾는 항목이 없음.)

P.s.2 bool 
searchAllChildren 은 하위레벨 노드를 검색할 지 판단 변수이다. false로 하면 같은 레벨 노드에서만 검색을 한다.
        나는 같은 레벨에서 검색이 필요하기 때문에 false를 했다.

반응형

'Programming > C#' 카테고리의 다른 글

effective c# - 1  (0) 2011.11.29
TreeNode Visual C# 도구 설명을 추가하는 방법  (0) 2011.11.21
C# C++ COM Interop  (0) 2011.11.15
C#에서 포인터  (0) 2011.11.15
TreeView 이용하기(추가/선택삭제/체크삭제)  (0) 2011.11.14
Posted by blueasa
, |