Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

how to convert a int into a bool unity

using System;
bool b = Convert.ToBoolean(i);
Comment

integer to boolean conversion in unity C#

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 :: using c# 
Csharp :: c# escape quotes 
Csharp :: list dictionary c# 
Csharp :: unity reload script assemblies 
Csharp :: access audio source from gameobject unity 
Csharp :: unity stack overflow error 
Csharp :: unity iOS app rating widget 
Csharp :: c++ Write a program to reverse an array or string 
Csharp :: euler angles to quaternion unity 
Csharp :: c# second last index 
Csharp :: c# is not marked as serializable 
Csharp :: c# arraylist to listview 
Csharp :: Nullable Types unity 
Csharp :: how to move balance from one card to another target 
Csharp :: weakreference tryget c# 
Csharp :: laravel get current url 
Html :: font awesome icon for email 
Html :: html starter code 
Html :: html new tab 
Html :: print page button html 
Html :: Uncaught ReferenceError: jQuery is not defined 
Html :: how to change website icon html 
Html :: adding a favicon in html 
Html :: web3 cdn 
Html :: regex to remove html tags python 
Html :: how do i set a pdf to be download link in html 
Html :: ckeditor cdn 
Html :: html star symbol 
Html :: svg line 
Html :: align image center of webpage 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =