Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

unity c# bool to int conversion

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 Elements 
Csharp :: c# capitalize first letter of each word in a string 
Csharp :: dotnet core webapp 
Csharp :: how to round in c# 
Csharp :: get sites ip in C# 
Csharp :: c# is string nullable 
Csharp :: unity in app review 
Csharp :: array in unity 
Csharp :: timespan format string c# 
Csharp :: unity3d sort list 
Csharp :: google tradutor 
Csharp :: c# get regedit value 
Csharp :: How to make a drawer in unity 
Csharp :: unity input tastiera 
Csharp :: c# .net stringify data query 
Csharp :: css text no word wrap 
Html :: html empty character 
Html :: how to change a favicon in html 
Html :: sample text 
Html :: how to specify amout of letters in inputfield in css 
Html :: python jupyter markdown color 
Html :: how to add favicon in html 
Html :: add favicon to html 
Html :: html a tag underline none 
Html :: vue datatable date format 
Html :: javascript generate pdf from div content jquery 
Html :: html file 
Html :: download ebook free 
Html :: div contenteditable onchange angular 
Html :: back link a html 
ADD CONTENT
Topic
Content
Source link
Name
7+7 =