Clone
How do I use Clone
Below are practical examples compiled from projects for learning and reference purposes
Featured Snippets
File name: ClickDetector.cs
Copy
7 void Update()
8 {
9 // if this player is not "it", the player can't tag anyone, so don't do anything on collision
10 if (PhotonNetwork.player.ID != GameLogic.playerWhoIsIt)
11 {
12 return;
13 }
14
15 if (Input.GetButton("Fire1"))
16 {
17 GameObject goPointedAt = RaycastObject(Input.mousePosition);
18
19 if (goPointedAt != null && goPointedAt != this.gameObject && goPointedAt.name.Equals("monsterprefab(Clone)", StringComparison.OrdinalIgnoreCase))
20 {
21 PhotonView rootView = goPointedAt.transform.root.GetComponent
22 GameLogic.TagPlayer(rootView.owner.ID);
23 }
24 }
25 }
File name: Filters.cs
Copy
114 public static bool Conv3x3(Bitmap b, ConvMatrix m)
115 {
116 // Avoid divide by zero errors
117 if (0 == m.Factor) return false;
118
119 Bitmap bSrc = (Bitmap)b.Clone();
120
121 // GDI+ still lies to us - the return format is BGR, NOT RGB.
122 BitmapData bmData = b.LockBits(new Rectangle(0, 0, b.Width, b.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
123 BitmapData bmSrc = bSrc.LockBits(new Rectangle(0, 0, bSrc.Width, bSrc.Height), ImageLockMode.ReadWrite, PixelFormat.Format24bppRgb);
124
125 int stride = bmData.Stride;
126 int stride2 = stride * 2;
127 System.IntPtr Scan0 = bmData.Scan0;
128 System.IntPtr SrcScan0 = bmSrc.Scan0;
129
130 unsafe
131 {
132 byte * p = (byte *)(void *)Scan0;
133 byte * pSrc = (byte *)(void *)SrcScan0;
134
135 int nOffset = stride + 6 - b.Width*3;
136 int nWidth = b.Width - 2;
137 int nHeight = b.Height - 2;
138
139 int nPixel;
140
141 for(int y=0;y < nHeight;++y)
142 {
143 for(int x=0; x < nWidth; ++x )
144 {
145 nPixel = ( ( ( (pSrc[2] * m.TopLeft) + (pSrc[5] * m.TopMid) + (pSrc[8] * m.TopRight) +
146 (pSrc[2 + stride] * m.MidLeft) + (pSrc[5 + stride] * m.Pixel) + (pSrc[8 + stride] * m.MidRight) +
147 (pSrc[2 + stride2] * m.BottomLeft) + (pSrc[5 + stride2] * m.BottomMid) + (pSrc[8 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);
148
149 if (nPixel < 0) nPixel = 0;
150 if (nPixel > 255) nPixel = 255;
151
152 p[5 + stride]= (byte)nPixel;
153
154 nPixel = ( ( ( (pSrc[1] * m.TopLeft) + (pSrc[4] * m.TopMid) + (pSrc[7] * m.TopRight) +
155 (pSrc[1 + stride] * m.MidLeft) + (pSrc[4 + stride] * m.Pixel) + (pSrc[7 + stride] * m.MidRight) +
156 (pSrc[1 + stride2] * m.BottomLeft) + (pSrc[4 + stride2] * m.BottomMid) + (pSrc[7 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);
157
158 if (nPixel < 0) nPixel = 0;
159 if (nPixel > 255) nPixel = 255;
160
161 p[4 + stride] = (byte)nPixel;
162
163 nPixel = ( ( ( (pSrc[0] * m.TopLeft) + (pSrc[3] * m.TopMid) + (pSrc[6] * m.TopRight) +
164 (pSrc[0 + stride] * m.MidLeft) + (pSrc[3 + stride] * m.Pixel) + (pSrc[6 + stride] * m.MidRight) +
165 (pSrc[0 + stride2] * m.BottomLeft) + (pSrc[3 + stride2] * m.BottomMid) + (pSrc[6 + stride2] * m.BottomRight)) / m.Factor) + m.Offset);
166
167 if (nPixel < 0) nPixel = 0;
168 if (nPixel > 255) nPixel = 255;
169
170 p[3 + stride] = (byte)nPixel;
171
172 p += 3;
173 pSrc += 3;
174 }
175
176 p += nOffset;
177 pSrc += nOffset;
178 }
179 }
180
181 b.UnlockBits(bmData);
182 bSrc.UnlockBits(bmSrc);
183
184 return true;
185 }
Clone 104 lượt xem
Gõ tìm kiếm nhanh...