void MyAwake() { Touched = false; jetpack = false; gameOver = false; jump = false; nonStopActived = false; inTheWater = false; //Resources.UnloadUnusedAssets(); carSp = (CarSpawner)GameObject.FindObjectOfType(typeof(CarSpawner)); areaSp = (AreaSpawner)GameObject.FindObjectOfType(typeof(AreaSpawner)); duckSpawner = (DuckSpawner)GameObject.FindObjectOfType(typeof(DuckSpawner)); sc = ScoreListener.getInstance(); controller = gameObject.GetComponent <CharacterController>(); screenCenter = Screen.width / 2; ChangeCam(); ChangeCam(); pivot = GameObject.Find("pivot").transform; sky = GameObject.Find("sky").transform; player = transform; State = eState.Stay; StatePoint = Random.Range(0, spawnPoints.Length); delta = Vector2.zero; CFallSpeed = 0; lives = 0; Vector3 playerpos = player.position; playerpos.x = spawnPoints[StatePoint]; player.transform.position = playerpos; sky.position = playerpos; if (pers != Pers.rabbit) { carSp.bonusPrefab[1] = BottleOrEgg; } if (pers == Pers.rabbit || pers == Pers.dog) { carSp.bonusPrefab[6] = carSp.bonusPrefab[0]; } }
private void OnSceneGUI() { system = target as AreaSpawner; handleTransform = system.transform; handleRotation = Tools.pivotRotation == PivotRotation.Local? handleTransform.rotation : Quaternion.identity; Vector3 topR, bottomL; Vector3[] p = new Vector3[4]; topR = handleTransform.TransformPoint(system.bottomL); bottomL = handleTransform.TransformPoint(system.topR); p[0].Set(bottomL.x, handleTransform.position.y, bottomL.z); p[1].Set(bottomL.x, handleTransform.position.y, topR.z); p[2].Set(topR.x, handleTransform.position.y, bottomL.z); p[3].Set(topR.x, handleTransform.position.y, topR.z); Handles.color = Color.yellow; Handles.DrawLine(p[0], p[1]); Handles.DrawLine(p[1], p[3]); Handles.DrawLine(p[3], p[2]); Handles.DrawLine(p[2], p[0]); Handles.DoPositionHandle(topR, handleRotation); Handles.DoPositionHandle(bottomL, handleRotation); EditorGUI.BeginChangeCheck(); topR = Handles.DoPositionHandle(topR, handleRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(system, "Move p0"); system.bottomL = handleTransform.InverseTransformPoint(topR); } EditorGUI.BeginChangeCheck(); bottomL = Handles.DoPositionHandle(bottomL, handleRotation); if (EditorGUI.EndChangeCheck()) { Undo.RecordObject(system, "Move p1"); system.topR = handleTransform.InverseTransformPoint(bottomL); } }
public void OnSceneGUI() { try { bu = (AreaSpawner)target; } catch { } Event girdi = Event.current; if (bu.duzenlemeModu) { if (ctrl != girdi.control) { if (girdi.control) { ctrl_ok = true; } ctrl = girdi.control; } if (girdi.shift && girdi.type == EventType.MouseDown) { Ray worldRay = HandleUtility.GUIPointToWorldRay(girdi.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(worldRay, out hitInfo, 10000)) { if (prev_point != hitInfo.point) { bu.YeniNokta(hitInfo.point, ctrl_ok && girdi.control); ctrl_ok = false; prev_point = hitInfo.point; } } } if (girdi.shift) { Selection.activeGameObject = bu.gameObject; } } if (girdi.keyCode == KeyCode.Backspace && girdi.type == EventType.KeyUp && bu.seciliAlan_id < bu.transform.childCount) { bu.transform.GetChild(bu.seciliAlan_id).GetComponent <HeyArea>().KendiniImhaEt(); } }
public override void OnInspectorGUI() { try { bu = (AreaSpawner)target; } catch { } GUIStyle baslikYaziTipi = GUIStyle.none; baslikYaziTipi.alignment = TextAnchor.MiddleCenter; baslikYaziTipi.fontSize = 15; baslikYaziTipi.fontStyle = FontStyle.Bold; baslikYaziTipi.normal.textColor = Color.white; GUILayout.Label("Hey\nArea Object Spawner v1.1", baslikYaziTipi); GUILayout.Space(5); sekme = GUILayout.Toolbar(sekme, new string[] { "Duzenleyici\n-Editor-", "Ayarlar\n-Settings-" }); switch (sekme) { case 0: { GUILayout.Space(5); GUI.backgroundColor = Color.yellow; EditorGUILayout.HelpBox("\n Developed by Halil Emre Yildiz - @Jahn_Star \n", MessageType.None, true); GUILayout.Space(5); GUI.backgroundColor = bu.duzenlemeModu ? Color.red : Color.cyan; if (GUILayout.Button(bu.duzenlemeModu ? "Duzenlemeden Cik\n-Exit Edit-" : "Duzenleme Modu\n-Edit Mode-")) { bu.duzenlemeModu = !bu.duzenlemeModu; Tools.current = bu.duzenlemeModu ? Tool.None : Tool.Move; } GUI.backgroundColor = Color.green; GUILayout.Space(5); if (bu.transform.childCount > 0 && bu.seciliAlan_id < bu.transform.childCount) { GUILayout.Label("Secili Alan - Selected Area: " + bu.seciliAlan_id, baslikYaziTipi); HeyArea seciliAlan = bu.transform.GetChild(bu.seciliAlan_id).GetComponent <HeyArea>(); bu.alanOzellikleri = EditorGUILayout.Foldout(bu.alanOzellikleri, "Nesneler -Objects-"); if (bu.alanOzellikleri) { List <SpawnObjectProperty> ozellikler = seciliAlan.nesneler != null ? seciliAlan.nesneler : new List <SpawnObjectProperty>(); try { if (seciliAlan.nesneler.Count > 0 && GUILayout.Button("Kopyala - Copy")) { bu.kopyalananOzellikler = ozellikler.ToList(); } if (bu.kopyalananOzellikler.Count != 0 && GUILayout.Button("Yapistir - Paste (" + bu.kopyalananOzellikler.Count + ")")) { ozellikler = bu.kopyalananOzellikler.ToList(); } if (bu.kopyalananOzellikler.Count != 0 && GUILayout.Button("Temizle - Clear Clipboard")) { bu.kopyalananOzellikler.Clear(); } Rect rect2 = EditorGUILayout.GetControlRect(false, 12f); rect2.height = 2f; EditorGUI.DrawRect(rect2, new Color(0.5f, 0.5f, 0.5f, 1)); } catch { } int sil = -1; for (int i = 0; i < ozellikler.Count; i++) { EditorGUILayout.BeginHorizontal(); ozellikler[i] = (SpawnObjectProperty)EditorGUILayout.ObjectField(ozellikler[i], typeof(SpawnObjectProperty), true); GUI.backgroundColor = Color.red; if (GUILayout.Button("-")) { sil = i; } GUI.backgroundColor = Color.green; EditorGUILayout.EndHorizontal(); } if (sil != -1) { ozellikler.RemoveAt(sil); } if (GUILayout.Button("+")) { ozellikler.Add(null); } seciliAlan.nesneler = ozellikler; GUILayout.Space(10); Rect rect = EditorGUILayout.GetControlRect(false, 12f); rect.height = 2f; EditorGUI.DrawRect(rect, new Color(0.5f, 0.5f, 0.5f, 1)); GUI.backgroundColor = Color.cyan; if (GUILayout.Button("Nesneleri Olustur\n-Spawn Objects-")) { if (bu.parentSpawnedObject == null) { bu.parentSpawnedObject = new GameObject("Created (HeySpawner)").transform; } for (int i = 0; i < seciliAlan.nesneler.Count; i++) { SpawnObjectProperty nesne = seciliAlan.nesneler[i]; if (!nesne) { break; } Transform objects = Creator.SpawnObjectInArea(nesne.nesne, nesne.rastgeleBoyut, nesne.rastgeleRotasyon, nesne.miktar, seciliAlan.transform, bu.parentSpawnedObject, nesne.tip); Selection.activeObject = objects; Undo.RegisterCreatedObjectUndo(objects.gameObject, "Create Object"); } } GUI.backgroundColor = Color.yellow; } if (GUILayout.Button("Alani Tasi\n-Move Area-")) { List <GameObject> noktalar = new List <GameObject>(); foreach (Transform nokta in seciliAlan.transform) { noktalar.Add(nokta.gameObject); } Selection.objects = noktalar.ToArray(); } GUI.backgroundColor = Color.red; if (GUILayout.Button("Alani Sil\n-Delete Area-")) { seciliAlan.gameObject.GetComponent <HeyArea>().KendiniImhaEt(); bu.AlanSec(bu.seciliAlan_id - 1); } GUILayout.Space(5); } else if (bu.transform.childCount > 0) { bu.AlanSec(bu.transform.childCount - 1); } GUI.backgroundColor = Color.cyan; try { EditorGUILayout.HelpBox("\n TR:\n Nokta Yarat: SHIFT+CLICK \n Alan Yarat: CTRL+SHIFT+CLICK \n Secili Alani Sil: BACKSPACE \n" + "\n EN:\n Create Point: SHIFT+CLICK \n Create Area: CTRL+SHIFT+CLICK \n Delete Selected Area: BACKSPACE \n\n If this doesn't work, you can try Reset All Layout.\n", MessageType.Info); if (GUILayout.Button("Click for Documentation")) { Application.OpenURL("https://github.com/JahnStar/Hey-Area-Object-Spawner"); } if (GUILayout.Button("Support the Developer")) { Application.OpenURL("https://jahnstar.github.io/donate/"); } } catch { } } break; case 1: base.OnInspectorGUI(); break; } }