SlideShare uma empresa Scribd logo
1 de 20
INTRO TO
UNITY SCRIPTING



   Emrah Özer
   Indie Game Developer
Neden Unity?
YENI BIR PLATFORMA
     BASLAMAK
YENI BIR PLATFORMA BASLARKEN

İlk baktığım konseptler:

•   Variable Definition

•   Method Definition

•   Instantiation

•   Messaging

•   Event Handling

•   Platform Spesific Features

•   MVC implementation
UNITY’YE BASLARKEN


•   Component Mimarisi Nedir

•   Component’lara Nasil Ulasilir

•   Objelere Nasil Ulasilir

•   Prefablar / Objeler Nasil Instantiate Edilir

•   Event Sistemi Nasil
DİL SEÇİMİ
                  C# Javascript

Tercihim C#:

•   Daha kati (strict typing) bir dil olmasi

•   IDE acisindan avantajli olmasi (Visual Studio rules)

•   Unity API’sinin naming convention seciminin bu yonde
    olmasi. (Büyük harfle başlayan method isimleri)

•   Event sisteminde kolaylık sağlaması
Accessing Components


•   Unity’de oyunumuzda kullandigimiz butun objeler
    GameObject’den extend ediyor.

•   Bir objenin kamera / kup / collider / light olduguna
    eklenen component’lar karar veriyor.

•   Objelerimize ekledigimiz component’larin hepsi aslinda
    birer script blogu (vice versa)
Accessing Components (cont...)


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void Example() {

         GetComponent<SomeScript>().doSomething();

    }
}
Accessing Objects


•   Inspector’a referans verilebilir


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    public Transform target;
    void Update() {
        target.Translate(0, 1, 0);
    }
}
Accessing Objects (cont...)

•   Ayni hiyerarsi icinde bulunan yani kendisine parent veya
    child olan objelere transform.Find() methodu ile ulasarak


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void Example() {
        transform.Find("Hand").Translate(0, 1, 0);
    }
}
Accessing Objects (cont...)

•                  ve FindObjectsOfType ile bir tipteki bütün
    FindObjectOfType
    scriptlere/componentlara ulaşılabilir.


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void Start() {
         OtherScript other = FindObjectOfType(typeof(OtherScript));
         other.DoSomething();
    }
}
Accessing Objects (cont...)

•   GameObject.Find()ve GameObject.FindWithTag() ile isim ve
    etikete gore arama yapilabilir.

using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void Start() {
        GameObject go = GameObject.Find("Haydar");
        go.transform.Translate(0, 1, 0);
        GameObject player = GameObject.FindWithTag("Player");
        player.transform.Translate(0, 1, 0);
    }
}
Accessing Objects (cont...)


•   Buradan yola çıkarak objelere bağlı scriptlere ulaşılabilir


using UnityEngine;
using System.Collections;

public class example : MonoBehaviour {
    void Start() {
        GameObject go = GameObject.Find("Murtaza");
        go.GetComponent<OtherScript>().DoSomething();
        GameObject player = GameObject.FindWithTag("Player");
        player.GetComponent<OtherScript>().DoSomething();
    }
}
HERKES HERŞEYE
 ULAŞABİLİR!!!
Instantiating
   •   Instantiate methodu, instantiate edilecek obje, rotasyon
       ve pozisyon verisiyle birlikte cagirilir.

Transform clonedObject = Instantiate(testObject,transform.position,transform.rotation)




                                  Destroy
   •   GameObject, component veya bir asset’i kaldirmak icin
       kullanilir
       Destroy(gameObject);
       Destroy();
       Destroy(rigidbody);
       Destroy(gameObject, 5);
Platform Spesific Features
•   Bu tip ozellikleri gorebilecegimiz yer MonoBehaviour
    class’i

Awake
Update
LateUpdate
FixedUpdate
Start

OnTriggerEnter
OnCollisionEnter
DEMO TIME

Mais conteúdo relacionado

Destaque

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfmarketingartwork
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsKurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summarySpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentLily Ray
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best PracticesVit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project managementMindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at WorkGetSmarter
 

Destaque (20)

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 

Emrah Özer : Introduction to Unity Scripting

  • 1.
  • 2. INTRO TO UNITY SCRIPTING Emrah Özer Indie Game Developer
  • 3.
  • 5.
  • 7. YENI BIR PLATFORMA BASLARKEN İlk baktığım konseptler: • Variable Definition • Method Definition • Instantiation • Messaging • Event Handling • Platform Spesific Features • MVC implementation
  • 8. UNITY’YE BASLARKEN • Component Mimarisi Nedir • Component’lara Nasil Ulasilir • Objelere Nasil Ulasilir • Prefablar / Objeler Nasil Instantiate Edilir • Event Sistemi Nasil
  • 9. DİL SEÇİMİ C# Javascript Tercihim C#: • Daha kati (strict typing) bir dil olmasi • IDE acisindan avantajli olmasi (Visual Studio rules) • Unity API’sinin naming convention seciminin bu yonde olmasi. (Büyük harfle başlayan method isimleri) • Event sisteminde kolaylık sağlaması
  • 10. Accessing Components • Unity’de oyunumuzda kullandigimiz butun objeler GameObject’den extend ediyor. • Bir objenin kamera / kup / collider / light olduguna eklenen component’lar karar veriyor. • Objelerimize ekledigimiz component’larin hepsi aslinda birer script blogu (vice versa)
  • 11. Accessing Components (cont...) using UnityEngine; using System.Collections; public class example : MonoBehaviour { void Example() { GetComponent<SomeScript>().doSomething(); } }
  • 12. Accessing Objects • Inspector’a referans verilebilir using UnityEngine; using System.Collections; public class example : MonoBehaviour { public Transform target; void Update() { target.Translate(0, 1, 0); } }
  • 13. Accessing Objects (cont...) • Ayni hiyerarsi icinde bulunan yani kendisine parent veya child olan objelere transform.Find() methodu ile ulasarak using UnityEngine; using System.Collections; public class example : MonoBehaviour { void Example() { transform.Find("Hand").Translate(0, 1, 0); } }
  • 14. Accessing Objects (cont...) • ve FindObjectsOfType ile bir tipteki bütün FindObjectOfType scriptlere/componentlara ulaşılabilir. using UnityEngine; using System.Collections; public class example : MonoBehaviour { void Start() { OtherScript other = FindObjectOfType(typeof(OtherScript)); other.DoSomething(); } }
  • 15. Accessing Objects (cont...) • GameObject.Find()ve GameObject.FindWithTag() ile isim ve etikete gore arama yapilabilir. using UnityEngine; using System.Collections; public class example : MonoBehaviour { void Start() { GameObject go = GameObject.Find("Haydar"); go.transform.Translate(0, 1, 0); GameObject player = GameObject.FindWithTag("Player"); player.transform.Translate(0, 1, 0); } }
  • 16. Accessing Objects (cont...) • Buradan yola çıkarak objelere bağlı scriptlere ulaşılabilir using UnityEngine; using System.Collections; public class example : MonoBehaviour { void Start() { GameObject go = GameObject.Find("Murtaza"); go.GetComponent<OtherScript>().DoSomething(); GameObject player = GameObject.FindWithTag("Player"); player.GetComponent<OtherScript>().DoSomething(); } }
  • 18. Instantiating • Instantiate methodu, instantiate edilecek obje, rotasyon ve pozisyon verisiyle birlikte cagirilir. Transform clonedObject = Instantiate(testObject,transform.position,transform.rotation) Destroy • GameObject, component veya bir asset’i kaldirmak icin kullanilir Destroy(gameObject); Destroy(); Destroy(rigidbody); Destroy(gameObject, 5);
  • 19. Platform Spesific Features • Bu tip ozellikleri gorebilecegimiz yer MonoBehaviour class’i Awake Update LateUpdate FixedUpdate Start OnTriggerEnter OnCollisionEnter

Notas do Editor

  1. \n
  2. \n
  3. \n
  4. \n
  5. \n
  6. \n
  7. \n
  8. \n
  9. \n
  10. \n
  11. \n
  12. \n
  13. \n
  14. \n
  15. \n
  16. \n
  17. \n
  18. \n
  19. \n
  20. \n
  21. \n