Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
ImageExample Class Reference
Inheritance diagram for ImageExample:

Classes

class  DropInfo
 

Private Member Functions

void OnEnable ()
 
void OnDisable ()
 
void OnFiles (List< string > aFiles, POINT aPos)
 
void LoadImage (int aIndex, DropInfo aInfo)
 
void OnGUI ()
 

Private Attributes

Texture2D[] textures = new Texture2D[6]
 
DropInfo dropInfo
 

Detailed Description

Definition at line 6 of file ImageExample.cs.

Member Function Documentation

◆ LoadImage()

void ImageExample.LoadImage ( int  aIndex,
DropInfo  aInfo 
)
inlineprivate

Definition at line 58 of file ImageExample.cs.

59 {
60 if (aInfo != null && GUILayoutUtility.GetLastRect().Contains(aInfo.pos))
61 {
62 byte[] data = File.ReadAllBytes(aInfo.file);
63 Texture2D texture2D = new Texture2D(1, 1);
64 texture2D.LoadImage(data);
65 if (textures[aIndex] != null)
66 {
67 Object.Destroy(textures[aIndex]);
68 }
69 textures[aIndex] = texture2D;
70 }
71 }
Texture2D[] textures
Definition: ImageExample.cs:15

References ImageExample.DropInfo.file, ImageExample.DropInfo.pos, and textures.

Referenced by OnGUI().

◆ OnDisable()

void ImageExample.OnDisable ( )
inlineprivate

◆ OnEnable()

void ImageExample.OnEnable ( )
inlineprivate

Definition at line 19 of file ImageExample.cs.

20 {
22 UnityDragAndDropHook.OnDroppedFiles += OnFiles;
23 }
void OnFiles(List< string > aFiles, POINT aPos)
Definition: ImageExample.cs:30

References B83.Win32.UnityDragAndDropHook.InstallHook(), and OnFiles().

◆ OnFiles()

void ImageExample.OnFiles ( List< string >  aFiles,
POINT  aPos 
)
inlineprivate

Definition at line 30 of file ImageExample.cs.

31 {
32 string text = "";
33 foreach (string aFile in aFiles)
34 {
35 switch (new FileInfo(aFile).Extension.ToLower())
36 {
37 case ".png":
38 case ".jpg":
39 case ".jpeg":
40 text = aFile;
41 goto end_IL_0053;
42 }
43 continue;
44 end_IL_0053:
45 break;
46 }
47 if (text != "")
48 {
49 DropInfo dropInfo = new DropInfo
50 {
51 file = text,
52 pos = new Vector2(aPos.x, aPos.y)
53 };
54 this.dropInfo = dropInfo;
55 }
56 }
DropInfo dropInfo
Definition: ImageExample.cs:17

References dropInfo.

Referenced by OnEnable().

◆ OnGUI()

void ImageExample.OnGUI ( )
inlineprivate

Definition at line 73 of file ImageExample.cs.

74 {
75 DropInfo aInfo = null;
76 if (Event.current.type == EventType.Repaint && dropInfo != null)
77 {
78 aInfo = dropInfo;
79 dropInfo = null;
80 }
81 GUILayout.BeginHorizontal();
82 for (int i = 0; i < 3; i++)
83 {
84 if (textures[i] != null)
85 {
86 GUILayout.Label(textures[i], GUILayout.Width(200f), GUILayout.Height(200f));
87 }
88 else
89 {
90 GUILayout.Box("Drag image here", GUILayout.Width(200f), GUILayout.Height(200f));
91 }
92 LoadImage(i, aInfo);
93 }
94 GUILayout.EndHorizontal();
95 GUILayout.BeginHorizontal();
96 for (int j = 3; j < 6; j++)
97 {
98 if (textures[j] != null)
99 {
100 GUILayout.Label(textures[j], GUILayout.Width(200f), GUILayout.Height(200f));
101 }
102 else
103 {
104 GUILayout.Box("Drag image here", GUILayout.Width(200f), GUILayout.Height(200f));
105 }
106 LoadImage(j, aInfo);
107 }
108 GUILayout.EndHorizontal();
109 }
void LoadImage(int aIndex, DropInfo aInfo)
Definition: ImageExample.cs:58

References dropInfo, LoadImage(), and textures.

Member Data Documentation

◆ dropInfo

DropInfo ImageExample.dropInfo
private

Definition at line 17 of file ImageExample.cs.

Referenced by OnFiles(), and OnGUI().

◆ textures

Texture2D [] ImageExample.textures = new Texture2D[6]
private

Definition at line 15 of file ImageExample.cs.

Referenced by LoadImage(), and OnGUI().


The documentation for this class was generated from the following file: