if\else structure fails

Hi, i have this code:

if(NextMapPartType==2)//chek corner    situations
    {
     Debug.Log(CurrentMapPart.transform.rotation.eulerAngles.y);
      if(CurrentMapPart.transform.rotation.eulerAngles.y==180)
        { 
           NextMapPartRotation=0;   
           NextMapPartPosition = Vector3(CurrentMapPart.transform.position.x-MapPartDefauldSize,0,CurrentMapPart.transform.position.z);
        }
      else if(CurrentMapPart.transform.rotation.eulerAngles.y==90)
        { 
           NextMapPartRotation=270;   
           NextMapPartPosition = Vector3(CurrentMapPart.transform.position.x+MapPartDefauldSize,0,CurrentMapPart.transform.position.z);
        }
      else if(CurrentMapPart.transform.rotation.eulerAngles.y==270)
        { 
           NextMapPartRotation=90;   
           NextMapPartPosition = Vector3(CurrentMapPart.transform.position.x,0,CurrentMapPart.transform.position.z+MapPartDefauldSize);
        }
      else if(CurrentMapPart.transform.rotation.eulerAngles.y==0)
        { 
           NextMapPartRotation=180;  
           NextMapPartPosition = Vector3(CurrentMapPart.transform.position.x,0,CurrentMapPart.transform.position.z+MapPartDefauldSize);
        }
 
    }

Debug message shows that y = 180, but this code never enters first if{} - why?

Floating point numbers are imprecise. The actual value might be 180.00000001, and giving the string conversion, you would not see the small extra value. You want to avoid comparing floating point numbers directly. You can compare against a range (the value is > 179.9 and < 181.1 for example) or you can use Mathf.Approximately() for your comparison.

Given the structure of you code here, you could also restructure the order of your if and use the < operator. < 0.1, else < 90.1, else < 180.1, else < 270.1…