Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity bool to int

using System.Collections;
using UnityEngine;

public class SampleClass : MonoBehaviour
{
	//Example
	private int sampleInteger = 1;
    private bool sampleBoolean = false;
	private void SampleMethod(){
    	sampleInteger = BoolToInt(sampleBoolean);	//=> false becomes 0
        sampleBoolean = IntToBool(sampleInteger);	//=> 1 becomes true
    }

	//Methods for conversion between Integer and Boolean types
    private bool IntToBool(int val){
        if (val == 1)
            return true;
        return false;
    }
    private int BoolToInt(bool val){
        if (val)
            return 1;
        return 0;
    }
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: maximum sum of non-adjacent 
Csharp :: c# get first word of string 
Csharp :: unity how to check object position 
Csharp :: list<string,string c# 
Csharp :: c# mapper.map 
Csharp :: c# stream 
Csharp :: app rating within game in unity 
Csharp :: ocr library for c# 
Csharp :: deserialize list of objects c# 
Csharp :: leantween move ui 
Csharp :: millie bobby brown age 
Csharp :: web scraping dynamic content c# 
Csharp :: hydrogen fuels 
Csharp :: unity colllion not working 
Csharp :: how to show error xtramessagebox in devexpress c# 
Csharp :: string to date 
Html :: how to use unsplash images in html 
Html :: htmjl favicons 
Html :: how to submit a form with submit button outside form 
Html :: how to remove suggestions from input field 
Html :: editable div 
Html :: add title logo html 
Html :: add favicon html 
Html :: conveert text to uppercase in input field 
Html :: prevent webpage zooming in mobile 
Html :: icons burger css font awesome 
Html :: how to validate mobile number in html form 
Html :: free ebooks 
Html :: dropdown in html 
Html :: accept zip codes in html 
ADD CONTENT
Topic
Content
Source link
Name
1+6 =