how to comparing name of gameobject

so i making simple game to put the right answer in the right slot. which is when you put the right sticker on the slot you got score. for the example if you put the sticker “a” to the slot “b” then you got point. and then the sticker “a”, the sticker become child of slot “b”. the problem is when i uses the name of the gameobject it doesnt work, i tried using debug.log to show the score but it doesnt work. this script is component of the slot. the draghandler is from another script the script is component of the sticker. here is the code
public void OnDrop (PointerEventData eventData)
{

    if (!item) {
        DragHandler.itemBeingDragged.transform.SetParent (transform);
        if (DragHandler.itemBeingDragged.gameObject.name == "b" && DragHandler.itemBeingDragged.transform.parent.name == "slot2") {
            score = score + 25;
            nilai = score.ToString();
            Debug.Log ("score: "+nilai);
        }}}

but when i used this code to show the name of slot and the sticker it’s work
public void OnDrop (PointerEventData eventData)
{

    if (!item) {
        DragHandler.itemBeingDragged.transform.SetParent (transform);
        Debug.Log ("slot: "+DragHandler.itemBeingDragged.transform.parent.name + "item : "+DragHandler.itemBeingDragged.gameObject.name);
        }
    }

sorry for my english, if there’s something wrong with my explanation let me know thank you

23 hours and no one answered you yet…? Maybe people watching the Olympus like me =P

I’m not really sure what you’re trying to ask for, but comparing gameObject name is as simple as comparing string. Read .NET documentation on how to compare string. If you really want to sacrifice some processing power (minute really)

DragHandler.itemBeingDragged.gameObject.name.equals("b");
DragHandler.itemBeingDragged.gameObject.transform.parent.equals("b");

Your code has an error somewhere…? Double click on the error that Unity gives you will tell you what line the error is on.

Anyway,

Is your game like pool? As in hit the ball into the hole and you get points as long as it the correct ball (stripped or solid)? If that the case, should have say so. Use analogy that everyone can understand.

Use gameObject.tag for simplicity and prevent multiple gameObject having the same name on the hierarchy. It will be a nightmare to sort through them for debugging etc… Plus you can have use gameObject.name for something else.