No Cancer RP

Full Version: Friendly Animals
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Here's a simple Unity C# script that creates an array of 'Animal' objects and has a method 'MakeFriends()' which prints a friendly message for each animal in the array:
Code:
using System.Collections.Generic;
using UnityEngine;

public class FriendlyAnimals : MonoBehaviour
{
    public List<Animal> animals = new List<Animal>();

    void Start()
    {
        MakeFriends();
    }

    void MakeFriends()
    {
        foreach (Animal animal in animals)
        {
            Debug.Log(animal.name + " says: Hi there! I'm a friendly " + animal.type + "!");
        }
    }
}
This script assumes that there is a 'Animal' class with 'name' and 'type' properties. You can modify this script to fit your specific needs.

To use this script, you would need to create some 'Animal' objects and add them to the 'animals' list in the 'FriendlyAnimals' script. Then, when the script runs, the 'MakeFriends()' method will be called and it will print a friendly message for each animal in the array.
I like animals

wait not like that

I think they are cool
+rep best mod
accepted