🔸متد Sleep() در ترد نویسی
در مبحث ترد نویسی،از این متد برای ایجاد تاخیر در حلقه استفاده می شود.(مثال: 200 میلی ثانیه):
using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
Thread.Sleep(200);
}
}
}
در مبحث ترد نویسی،از این متد برای ایجاد تاخیر در حلقه استفاده می شود.(مثال: 200 میلی ثانیه):
using System;
using System.Threading;
public class MyThread
{
public void Thread1()
{
for (int i = 0; i < 10; i++)
{
Console.WriteLine(i);
Thread.Sleep(200);
}
}
}
🔸ایجاد یک تایمر با سیشارپ،ساخت تایمر در سیشارپ
using System;
using System.Timers;
class myApp
{
public static void Main()
{
Timer myTimer = new Timer();
myTimer.Elapsed += new ElapsedEventHandler( DisplayTimeEvent );
myTimer.Interval = 1000;
myTimer.Start();
while ( Console.Read() != 'q' )
{
; // do nothing...
}
}
public static void DisplayTimeEvent( object source, ElapsedEventArgs e )
{
Console.Write("\r{0}", DateTime.Now);
}
}
@Unity_Scripts
using System;
using System.Timers;
class myApp
{
public static void Main()
{
Timer myTimer = new Timer();
myTimer.Elapsed += new ElapsedEventHandler( DisplayTimeEvent );
myTimer.Interval = 1000;
myTimer.Start();
while ( Console.Read() != 'q' )
{
; // do nothing...
}
}
public static void DisplayTimeEvent( object source, ElapsedEventArgs e )
{
Console.Write("\r{0}", DateTime.Now);
}
}
@Unity_Scripts
🔸ساختار سوئیچ در سیشارپ
✔️ مثال
using System;
public class Example
{
public static void Main()
{
int caseSwitch = 1;
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}
}
}
// The example displays the following output:
// Case 1
@Unity_Scripts
✔️ مثال
using System;
public class Example
{
public static void Main()
{
int caseSwitch = 1;
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}
}
}
// The example displays the following output:
// Case 1
@Unity_Scripts
🔸حلقه ی تکرار while:
while(condition){
//code to be executed
}
✔️مثال:نمایش اعداد 1 تا 10
using System;
public class WhileExample
{
public static void Main(string[] args)
{
int i=1;
while(i<=10)
{
Console.WriteLine(i);
i++;
}
}
}
➖Output:
1
2
3
4
5
6
7
8
9
10
✔️مثال:حلقه ی While تو در تو :
using System;
public class WhileExample
{
public static void Main(string[] args)
{
int i=1;
while(i<=3)
{
int j = 1;
while (j <= 3)
{
Console.WriteLine(i+" "+j);
j++;
}
i++;
}
}
}
➖Output:
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
✔️مثال:حلقه ی while بی پایان
(شرط حلقه همیشه درست یا true باشد):
using System;
public class WhileExample
{
public static void Main(string[] args)
{
while(true)
{
Console.WriteLine("Infinitive While Loop");
}
}
}
➖Output:
Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
ctrl+c
@Unity_Scripts
while(condition){
//code to be executed
}
✔️مثال:نمایش اعداد 1 تا 10
using System;
public class WhileExample
{
public static void Main(string[] args)
{
int i=1;
while(i<=10)
{
Console.WriteLine(i);
i++;
}
}
}
➖Output:
1
2
3
4
5
6
7
8
9
10
✔️مثال:حلقه ی While تو در تو :
using System;
public class WhileExample
{
public static void Main(string[] args)
{
int i=1;
while(i<=3)
{
int j = 1;
while (j <= 3)
{
Console.WriteLine(i+" "+j);
j++;
}
i++;
}
}
}
➖Output:
1 1
1 2
1 3
2 1
2 2
2 3
3 1
3 2
3 3
✔️مثال:حلقه ی while بی پایان
(شرط حلقه همیشه درست یا true باشد):
using System;
public class WhileExample
{
public static void Main(string[] args)
{
while(true)
{
Console.WriteLine("Infinitive While Loop");
}
}
}
➖Output:
Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
Infinitive While Loop
ctrl+c
@Unity_Scripts
سلام دوستان شما به ما بگید که چه پکیجی رو دوست دارید ما بسازیم برای شما که بخریدش به ما بگید در آی دی زیر
@Erfan_R1380
و تمام این پکیج ها در کانال زیر
@Unity_Package
@Erfan_R1380
و تمام این پکیج ها در کانال زیر
@Unity_Package
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
public GameObject[] Boxse;
public Vector3 TranslateSpeed = Vector3.zero;
public float MaxY = 20f;
void Start () {
StartCoroutine ("MoveBoxes");
}
void Updete(){
}
IEnumerator MoveBoxes(){
yield return new WaitForSeconds (2f);
foreach (GameObject Box in Boxse) {
while(Box.transform.position.y < MaxY){
Box.transform.Translate ( TranslateSpeed.x*Time.deltaTime,TranslateSpeed.y*Time.deltaTime,TranslateSpeed.z*Time.deltaTime);
yield return null;
}
}
}
}
using System.Collections.Generic;
using UnityEngine;
public class NewBehaviourScript : MonoBehaviour {
public GameObject[] Boxse;
public Vector3 TranslateSpeed = Vector3.zero;
public float MaxY = 20f;
void Start () {
StartCoroutine ("MoveBoxes");
}
void Updete(){
}
IEnumerator MoveBoxes(){
yield return new WaitForSeconds (2f);
foreach (GameObject Box in Boxse) {
while(Box.transform.position.y < MaxY){
Box.transform.Translate ( TranslateSpeed.x*Time.deltaTime,TranslateSpeed.y*Time.deltaTime,TranslateSpeed.z*Time.deltaTime);
yield return null;
}
}
}
}
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
// attach to UI Text component (with the full text already there)
public class UITextTypeWriter : MonoBehaviour {
Text txt;
string story;
void Awake () {
txt = GetComponent<Text> ();
story = txt.text;
txt.text = ""; // TODO: add optional delay when to start
StartCoroutine ("PlayText");
}
IEnumerator PlayText() {
foreach (char c in story) {
txt.text += c;
yield return new WaitForSeconds (0.125f);
}
}
}
using System.Collections;
using UnityEngine.UI;
// attach to UI Text component (with the full text already there)
public class UITextTypeWriter : MonoBehaviour {
Text txt;
string story;
void Awake () {
txt = GetComponent<Text> ();
story = txt.text;
txt.text = ""; // TODO: add optional delay when to start
StartCoroutine ("PlayText");
}
IEnumerator PlayText() {
foreach (char c in story) {
txt.text += c;
yield return new WaitForSeconds (0.125f);
}
}
}
اسکریپت اجرای فیلم در یونیتی👇
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public MovieTexture film1;
void Start() {
renderer.material.mainTexture = film1;
film1.Play();
}
}
@Unity_Scripts
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
public MovieTexture film1;
void Start() {
renderer.material.mainTexture = film1;
film1.Play();
}
}
@Unity_Scripts
تایپ خودکار متن در یونیتی :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
// attach to UI Text component (with the full text already there)
public class UITextTypeWriter : MonoBehaviour {
Text txt;
string story;
void Awake () {
txt = GetComponent<Text> ();
story = txt.text;
txt.text = ""; // TODO: add optional delay when to start
StartCoroutine ("PlayText");
}
IEnumerator PlayText() {
foreach (char c in story) {
txt.text += c;
yield return new WaitForSeconds (0.125f);
}
}
}
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
// attach to UI Text component (with the full text already there)
public class UITextTypeWriter : MonoBehaviour {
Text txt;
string story;
void Awake () {
txt = GetComponent<Text> ();
story = txt.text;
txt.text = ""; // TODO: add optional delay when to start
StartCoroutine ("PlayText");
}
IEnumerator PlayText() {
foreach (char c in story) {
txt.text += c;
yield return new WaitForSeconds (0.125f);
}
}
}
🔸عکس گرفتن از صفحه در یونیتی
Obsolete public static void CaptureScreenshot(string fileName, int superSize);
Obsolete public static void CaptureScreenshot(string filename);
filename مسیر ذخیره فایل اسکرین شات
superSize فاکتور افزایش کیفیت
✔️مثال:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void OnMouseDown() {
Application.CaptureScreenshot("Screenshot.png");
}
}
@Unity_Scripts
Obsolete public static void CaptureScreenshot(string fileName, int superSize);
Obsolete public static void CaptureScreenshot(string filename);
filename مسیر ذخیره فایل اسکرین شات
superSize فاکتور افزایش کیفیت
✔️مثال:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void OnMouseDown() {
Application.CaptureScreenshot("Screenshot.png");
}
}
@Unity_Scripts
Unity Learns
کلی آموزش های رایگان با بررسی و اشکال گیری آن همه در این کانال جهت عضویت در این کانال روی لینک های آبی کلیک کنید.
هر ماه به نفرات فعال در کانال و گروه تخفیف خرید پکیج های استثنایی خودمون رو هم بهتون می دیم.
_____________________
😂😁ما حتی تو تبلیغ ها مون هم مطلب یاد شما می دهیم
void Join () {
@Unity_Learns //کانالی پر پکیج آموزشی یونیتی
@Unity_Scripts //کانالی پر کد های یونیتی
@Unity_Package //کانالی پر پکیج کاربردی یونیتی
}
کلی آموزش های رایگان با بررسی و اشکال گیری آن همه در این کانال جهت عضویت در این کانال روی لینک های آبی کلیک کنید.
هر ماه به نفرات فعال در کانال و گروه تخفیف خرید پکیج های استثنایی خودمون رو هم بهتون می دیم.
_____________________
😂😁ما حتی تو تبلیغ ها مون هم مطلب یاد شما می دهیم
void Join () {
@Unity_Learns //کانالی پر پکیج آموزشی یونیتی
@Unity_Scripts //کانالی پر کد های یونیتی
@Unity_Package //کانالی پر پکیج کاربردی یونیتی
}
Forwarded from اتچ بات
Unity Learns
کانال پکیج های آموزشی یونیتی که اگه می خوای یونیتی یاد بگیری فقط کافی اینجا عضو بشی برای عضویت روی آیدی آبی پایین بزن.
به زودی پکیج بزرگی در این کانال منتشر می شود که مقدمش رو گزاشتم تو کانال @Unity_Package
الان در حال ظبط است.
@Unity_Learns
کانال پکیج های آموزشی یونیتی که اگه می خوای یونیتی یاد بگیری فقط کافی اینجا عضو بشی برای عضویت روی آیدی آبی پایین بزن.
به زودی پکیج بزرگی در این کانال منتشر می شود که مقدمش رو گزاشتم تو کانال @Unity_Package
الان در حال ظبط است.
@Unity_Learns
Telegram
attach 📎
گرافیک با آرامش
با موضوعات:
چگونه از فتوشاپ کسب درآمد کنیم؟
چگونه یونیتی را بیاموزیم؟
چگونه در انیمیشن سازی حرفه ای شویم؟
منبعی عظیم از هر چی که به گرافیک ربط پیدا کنه
متفاوت یاد بگیر: http://gerax.ir
با موضوعات:
چگونه از فتوشاپ کسب درآمد کنیم؟
چگونه یونیتی را بیاموزیم؟
چگونه در انیمیشن سازی حرفه ای شویم؟
منبعی عظیم از هر چی که به گرافیک ربط پیدا کنه
متفاوت یاد بگیر: http://gerax.ir
نمایش یک پیام هر 12 ساعت:
using UnityEngine.UI;
using System.Collections;
public class Move : MonoBehaviour {
public Text label1;
void Update()
{
int intHour=System.DateTime.Now.Hour;
if(intHour==12 || intHour==24)
{
label1.text=intHour.toString();
}
}
using UnityEngine.UI;
using System.Collections;
public class Move : MonoBehaviour {
public Text label1;
void Update()
{
int intHour=System.DateTime.Now.Hour;
if(intHour==12 || intHour==24)
{
label1.text=intHour.toString();
}
}
تایپ خودکار متن در یونیتی :
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
// attach to UI Text component (with the full text already there)
public class UITextTypeWriter : MonoBehaviour {
Text txt;
string story;
void Awake () {
txt = GetComponent<Text> ();
story = txt.text;
txt.text = ""; // TODO: add optional delay when to start
StartCoroutine ("PlayText");
}
IEnumerator PlayText() {
foreach (char c in story) {
txt.text += c;
yield return new WaitForSeconds (0.125f);
}
}
}
using UnityEngine;
using System.Collections;
using UnityEngine.UI;
// attach to UI Text component (with the full text already there)
public class UITextTypeWriter : MonoBehaviour {
Text txt;
string story;
void Awake () {
txt = GetComponent<Text> ();
story = txt.text;
txt.text = ""; // TODO: add optional delay when to start
StartCoroutine ("PlayText");
}
IEnumerator PlayText() {
foreach (char c in story) {
txt.text += c;
yield return new WaitForSeconds (0.125f);
}
}
}
🔸عکس گرفتن از صفحه در یونیتی
Obsolete public static void CaptureScreenshot(string fileName, int superSize);
Obsolete public static void CaptureScreenshot(string filename);
filename مسیر ذخیره فایل اسکرین شات
superSize فاکتور افزایش کیفیت
✔️مثال:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void OnMouseDown() {
Application.CaptureScreenshot("Screenshot.png");
}
}
Obsolete public static void CaptureScreenshot(string fileName, int superSize);
Obsolete public static void CaptureScreenshot(string filename);
filename مسیر ذخیره فایل اسکرین شات
superSize فاکتور افزایش کیفیت
✔️مثال:
using UnityEngine;
using System.Collections;
public class ExampleClass : MonoBehaviour {
void OnMouseDown() {
Application.CaptureScreenshot("Screenshot.png");
}
}
✅ آندرس هایلسبرگ:خالق سیشارپ
🔸او سازنده اصلی توربو پاسکال و طراح اصلی دلفی است. او هم اکنون برای مایکروسافت به عنوان طراح ارشد سیشارپ و توسعهدهندهٔ هسته تایپاسکریپت کار میکند.
@Unity_Learn
🔸او سازنده اصلی توربو پاسکال و طراح اصلی دلفی است. او هم اکنون برای مایکروسافت به عنوان طراح ارشد سیشارپ و توسعهدهندهٔ هسته تایپاسکریپت کار میکند.
@Unity_Learn
چک کردن اتصال به اینترنت در یونیتی
@Unity_Learns
کد:
var url : String = "ادرس یک سایت مثلا گوگل";
function Start(){
var www : WWW = new WWW(url);
yield www;
if(www.isDone && www.bytesDownloaded > 0){
print("Done :) ");
}
if(www.isDone && www.bytesDownloaded == 0){
print("No connection :(");
}
}
@Unity_Learns
کد:
var url : String = "ادرس یک سایت مثلا گوگل";
function Start(){
var www : WWW = new WWW(url);
yield www;
if(www.isDone && www.bytesDownloaded > 0){
print("Done :) ");
}
if(www.isDone && www.bytesDownloaded == 0){
print("No connection :(");
}
}