No Cancer RP
epic server


Friendly Animals
TargetRuins Offline
Junior Member
#1
Photo 
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.
Reply

|NC|RP| Aws0me Offline
Owner
#2
I like animals

wait not like that

I think they are cool
owner guy

Check out my YouTube and Twitch if you want.

Join The No Cancer RP Discord for updates and more.
Reply

rabbit. Offline
Member
#3
+rep best mod
accepted
rabbit. lmao https://www.youtube.com/watch?v=exlQjoXMm8M 
All mighty Head Admin
Reply





Users browsing this thread:
1 Guest(s)



Theme © iAndrew 2018 - Forum software by © MyBB .