Dinamik Crosshair

WM06

Uzman üye
31 Ara 2015
1,134
0
Kod:
@script ExecuteInEditMode() enum preset { none, shotgunPreset, crysisPreset } var crosshairPreset : preset = preset.none;   var showCrosshair : boolean = true; var verticalTexture : Texture; var horizontalTexture : Texture;   //Size of boxes var cLength : float = 10; var cWidth : float = 3;   //Spreed setup var minSpread : float = 45.0; var maxSpread : float = 250.0; var spreadPerSecond : float = 150.0;   //Rotation var rotAngle : float = 0.0; var rotSpeed : float = 0.0;   private var temp : Texture; private var spread : float;   function Update(){         //Used just for test (weapon script should change spread).         if(Input.GetKey(KeyCode.K)) spread += spreadPerSecond * Time.deltaTime;         else spread -= spreadPerSecond * 2 * Time.deltaTime;                    //Rotation         rotAngle += rotSpeed * Time.deltaTime; }   function OnGUI(){         if(showCrosshair && verticalTexture && horizontalTexture){                 var verticalT = GUIStyle();                 var horizontalT = GUIStyle();                 verticalT.normal.background = verticalTexture;                 horizontalT.normal.background = horizontalTexture;                 spread = Mathf.Clamp(spread, minSpread, maxSpread);                 var pivot : Vector2 = Vector2(Screen.width/2, Screen.height/2);                                 if(crosshairPreset == preset.crysisPreset){                                                 GUI.Box(Rect((Screen.width - 2)/2, (Screen.height - spread)/2 - 14, 2, 14), temp, horizontalT);                         GUIUtility.RotateAroundPivot(45,pivot);                         GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 2)/2, 14, 2), temp, verticalT);                         GUIUtility.RotateAroundPivot(0,pivot);                         GUI.Box(Rect((Screen.width - 2)/2, (Screen.height + spread)/2, 2, 14), temp, horizontalT);                 }                                 if(crosshairPreset == preset.shotgunPreset){                                         GUIUtility.RotateAroundPivot(45,pivot);                                                 //Horizontal                         GUI.Box(Rect((Screen.width - 14)/2, (Screen.height - spread)/2 - 3, 14, 3), temp, horizontalT);                         GUI.Box(Rect((Screen.width - 14)/2, (Screen.height + spread)/2, 14, 3), temp, horizontalT);                         //Vertical                         GUI.Box(Rect((Screen.width - spread)/2 - 3, (Screen.height - 14)/2, 3, 14), temp, verticalT);                         GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 14)/2, 3, 14), temp, verticalT);                 }                                 if(crosshairPreset == preset.none){                                         GUIUtility.RotateAroundPivot(rotAngle%360,pivot);                                                 //Horizontal                         GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height - spread)/2 - cLength, cWidth, cLength), temp, horizontalT);                         GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height + spread)/2, cWidth, cLength), temp, horizontalT);                         //Vertical                         GUI.Box(Rect((Screen.width - spread)/2 - cLength, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT);                         GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT);                 }         } }
 

Daedalus

Üye
11 Tem 2015
216
0
Kod:
@script ExecuteInEditMode() enum preset { none, shotgunPreset, crysisPreset } var crosshairPreset : preset = preset.none;   var showCrosshair : boolean = true; var verticalTexture : Texture; var horizontalTexture : Texture;   //Size of boxes var cLength : float = 10; var cWidth : float = 3;   //Spreed setup var minSpread : float = 45.0; var maxSpread : float = 250.0; var spreadPerSecond : float = 150.0;   //Rotation var rotAngle : float = 0.0; var rotSpeed : float = 0.0;   private var temp : Texture; private var spread : float;   function Update(){         //Used just for test (weapon script should change spread).         if(Input.GetKey(KeyCode.K)) spread += spreadPerSecond * Time.deltaTime;         else spread -= spreadPerSecond * 2 * Time.deltaTime;                    //Rotation         rotAngle += rotSpeed * Time.deltaTime; }   function OnGUI(){         if(showCrosshair && verticalTexture && horizontalTexture){                 var verticalT = GUIStyle();                 var horizontalT = GUIStyle();                 verticalT.normal.background = verticalTexture;                 horizontalT.normal.background = horizontalTexture;                 spread = Mathf.Clamp(spread, minSpread, maxSpread);                 var pivot : Vector2 = Vector2(Screen.width/2, Screen.height/2);                                 if(crosshairPreset == preset.crysisPreset){                                                 GUI.Box(Rect((Screen.width - 2)/2, (Screen.height - spread)/2 - 14, 2, 14), temp, horizontalT);                         GUIUtility.RotateAroundPivot(45,pivot);                         GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 2)/2, 14, 2), temp, verticalT);                         GUIUtility.RotateAroundPivot(0,pivot);                         GUI.Box(Rect((Screen.width - 2)/2, (Screen.height + spread)/2, 2, 14), temp, horizontalT);                 }                                 if(crosshairPreset == preset.shotgunPreset){                                         GUIUtility.RotateAroundPivot(45,pivot);                                                 //Horizontal                         GUI.Box(Rect((Screen.width - 14)/2, (Screen.height - spread)/2 - 3, 14, 3), temp, horizontalT);                         GUI.Box(Rect((Screen.width - 14)/2, (Screen.height + spread)/2, 14, 3), temp, horizontalT);                         //Vertical                         GUI.Box(Rect((Screen.width - spread)/2 - 3, (Screen.height - 14)/2, 3, 14), temp, verticalT);                         GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - 14)/2, 3, 14), temp, verticalT);                 }                                 if(crosshairPreset == preset.none){                                         GUIUtility.RotateAroundPivot(rotAngle%360,pivot);                                                 //Horizontal                         GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height - spread)/2 - cLength, cWidth, cLength), temp, horizontalT);                         GUI.Box(Rect((Screen.width - cWidth)/2, (Screen.height + spread)/2, cWidth, cLength), temp, horizontalT);                         //Vertical                         GUI.Box(Rect((Screen.width - spread)/2 - cLength, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT);                         GUI.Box(Rect((Screen.width + spread)/2, (Screen.height - cWidth)/2, cLength, cWidth), temp, verticalT);                 }         } }

Kod için teşekkürler birşey sormak istiyorum ben unity 4.6 kullanıyorum 4.6 da gui yok ui var fakat ui yi kodla oluşturmayı bulamadım bu konu hakkında bi bilginiz varmı veya bildiğiniz türkçe bir kaynak ?
 
Üst

Turkhackteam.org internet sitesi 5651 sayılı kanun’un 2. maddesinin 1. fıkrasının m) bendi ile aynı kanunun 5. maddesi kapsamında "Yer Sağlayıcı" konumundadır. İçerikler ön onay olmaksızın tamamen kullanıcılar tarafından oluşturulmaktadır. Turkhackteam.org; Yer sağlayıcı olarak, kullanıcılar tarafından oluşturulan içeriği ya da hukuka aykırı paylaşımı kontrol etmekle ya da araştırmakla yükümlü değildir. Türkhackteam saldırı timleri Türk sitelerine hiçbir zararlı faaliyette bulunmaz. Türkhackteam üyelerinin yaptığı bireysel hack faaliyetlerinden Türkhackteam sorumlu değildir. Sitelerinize Türkhackteam ismi kullanılarak hack faaliyetinde bulunulursa, site-sunucu erişim loglarından bu faaliyeti gerçekleştiren ip adresini tespit edip diğer kanıtlarla birlikte savcılığa suç duyurusunda bulununuz.