Error: An object reference is required to access non-static member (Enumerations)

using UnityEngine;
using System.Collections;

public class Click : MonoBehaviour {

	bool wasClicked = false;
	
	void OnMouseDown() {
  		wasClicked = true;
  		Activate();
	}
	
	public void Activate() {
   		renderer.material.color = Color.red;
		
		for(int i=0; i < Rohstoffe.Anderes.Length; i++)
		{
			Debug.Log (Rohstoffe.Anderes*);*
  •  }*
    
  •  for(int i=0; i < Rohstoffe.Edelsteine.Length; i++)*
    
  •  {*
    

_ Debug.Log (Rohstoffe.Anderes*);_
_
}*_

* for(int i=0; i < Rohstoffe.KraeuterPilze.Length; i++)*
* {*
_ Debug.Log (Rohstoffe.Anderes*);
}
}
}*
Rohstoffe.cs and Click.cs are attached to my sample gameobject (a simple cube) and I get those errors which I can’t solve myself:
Assets/Scripts/Click.cs(35,46): error CS0120: An object reference is required to access non-static member `Rohstoffe.Anderes’ (about six times)…
using UnityEngine;
using System;_

public class Rohstoffe : MonoBehaviour
{
* public Enumeration.AnderesEnum[] Anderes;*
* public Enumeration.EdelsteineEnum[] Edelsteine;*
* public Enumeration.KraeuterPilzeEnum[] KraeuterPilze;*
}
using UnityEngine;
using System;

public class Enumeration : MonoBehaviour
{
* public enum AnderesEnum*
* {*
* Kupfer = 0,*
* Eisen = 1,*
* Silber = 2,*
* Gold = 3,*
* Mithral = 4,*
* Arundur = 5,*

* Baumwolle = 6,*
* Haselnuss = 7,*
* Walnuss = 8,*
* Distel = 9,*
* Oliven = 10,*
* Mohn = 11,*

* Basalt = 12,*
* Granit = 13,*
* Lehm = 14,*
* Marmor = 15,*
* Sand = 16,*
* Ton = 17,*

* Fichte = 18,*
* Zalantharbaum = 19,*
* Wehrbaum = 20,*
* Suthbaum = 21,*
* Sumpfzypresse = 22,*
* Drachenbaum = 23,*
* Umbubaum = 24,*

* Flachs = 25,*
* Hanf = 26,*
* Bambus = 27,*

* Hirschfell = 28,*
* Wolfsfell = 29,*
* Pantherfell = 30,*
* Worgfell = 31,*
* Baerenfell = 32,*
* Tigerfell = 33,*

* Dachsblut = 34,*
* Wolfsblut = 35,*
* Pantherblut = 35,*
* Worgblut = 36,*
* Baerenblut = 37,*
* Adlerblut = 38,*
* Eulenblut = 39,*

* Adlerfedern = 40,*
* Eulenfeder = 41,*
* Seidenraupe = 42,*
* Skelettknoechel = 43,*
* Spinnendruese = 45,*
* };*

* public enum EdelsteineEnum*
* {*
* Amaratha = 50,*
* Amethyst = 51,*
* Aquamarin = 52,*
* Aventurin = 53,*
* Beljuril = 54,*
* Bergkristall = 55,*
* Bernstein = 56,*
* Chrysokoll = 57,*
* Citrin = 58,*
* Diamant = 59,*
* Falkenaugen = 60,*
* Feueropal = 61,*
* Gruftjade = 62,*
* Iol = 63,*
* Jacinth = 64,*
* Jade = 65,*
* Kanariendiamant = 66,*
* Katzenauge = 67,*
* Koenigstraene = 68,*
* Koralle = 69,*
* Kroetenstein = 70,*
* Kunzit = 71,*
* Lapislazuli = 72,*
* Malachit = 73,*
* Mandarin = 74,*
* Obsidian = 75,*
* Onyx = 76,*
* Phenalope = 77,*
* Rubin = 78,*
* Saphir = 79,*
* Sardonyx = 80,*
* Schurkenstein = 81,*
* Schwarzopal = 82,*
* Smaragd = 83,*
* Sternensaphir = 84,*
* Topas = 85,*
* };*

* public enum KraeuterPilzeEnum*
* {*
* Aloe = 100,*
* Arkasu = 101,*
* Arlan = 102,*
* Arunya = 103,*
* Baerentatze = 104,*
* Brokwilb = 105,*
* Brunnenkresse = 106,*
* Chronchinis = 107,*
* Eichhase = 108,*
* Eisenkraut = 109,*
* Goldrute = 110,*
* Hexenroehring = 111,*
* Hiradwurz = 112,*
* Johanniskraut = 113,*
* Katzenpfoetchen = 114,*
* Koenigskerze = 115,*
* Lathan = 116,*
* Maultierpollen = 117,*
* Merrig = 118,*
* Nachtschatten = 119,*
* Nebelkappe = 120,*
* Pantherpilz = 121,*
* Riesenbovist = 122,*
* Teufelskraut = 123,*
* Teufelszunge = 124,*
* Tigerritterling = 125,*
* Tintenfischpilz = 126,*
* Trudustbluete = 127,*
* Weidenroeschen = 128,*
* WeisserAndorn = 129,*
* Wolfskraut = 130*
* };*
}

There are two separate problems in your code, the first of which is easily resolved, but the second will require some understanding on your part.

First, enums do not need to be inside a class.

Destroy the class Enumeration completely and just leave the enums by themselves.

using UnityEngine;
using System;

public class Rohstoffe : MonoBehaviour
{
    public AnderesEnum[] Anderes;
    public EdelsteineEnum[] Edelsteine;
    public KraeuterPilzeEnum[] KraeuterPilze;
}

    public enum AnderesEnum
    {
       Kupfer = 0,
       Eisen = 1,
       Silber = 2,
       Gold = 3,
       Mithral = 4,
       Arundur = 5,

       Baumwolle = 6,
       Haselnuss = 7,
       Walnuss = 8,
       Distel = 9,
       Oliven = 10,
       Mohn = 11,

       Basalt = 12,
       Granit = 13,
       Lehm = 14,
       Marmor = 15,
       Sand = 16,
       Ton = 17,

       Fichte = 18,
       Zalantharbaum = 19,
       Wehrbaum = 20,
       Suthbaum = 21,
       Sumpfzypresse = 22,
       Drachenbaum = 23,
       Umbubaum = 24,

       Flachs = 25,
       Hanf = 26,
       Bambus = 27,

       Hirschfell = 28,
       Wolfsfell = 29,
       Pantherfell = 30,
       Worgfell = 31,
       Baerenfell = 32,
       Tigerfell = 33,

       Dachsblut = 34,
       Wolfsblut = 35,
       Pantherblut = 35,
       Worgblut = 36,
       Baerenblut = 37,
       Adlerblut = 38,
       Eulenblut = 39,

       Adlerfedern = 40,
       Eulenfeder = 41,
       Seidenraupe = 42,
       Skelettknoechel = 43,
       Spinnendruese = 45,
    };

    public enum EdelsteineEnum
    {
       Amaratha = 50,
       Amethyst = 51,
       Aquamarin = 52,
       Aventurin = 53,
       Beljuril = 54,
       Bergkristall = 55,
       Bernstein = 56,
       Chrysokoll = 57,
       Citrin = 58,
       Diamant = 59,
       Falkenaugen = 60,
       Feueropal = 61,
       Gruftjade = 62,
       Iol = 63,
       Jacinth = 64,
       Jade = 65,
       Kanariendiamant = 66,
       Katzenauge = 67,
       Koenigstraene = 68,
       Koralle = 69,
       Kroetenstein = 70,
       Kunzit = 71,
       Lapislazuli = 72,
       Malachit = 73,
       Mandarin = 74,
       Obsidian = 75,
       Onyx = 76,
       Phenalope = 77,
       Rubin = 78,
       Saphir = 79,
       Sardonyx = 80,
       Schurkenstein = 81,
       Schwarzopal = 82,
       Smaragd = 83, 
       Sternensaphir = 84,
       Topas = 85,
    };

    public enum KraeuterPilzeEnum
    {
       Aloe = 100,
       Arkasu = 101,
       Arlan = 102,
       Arunya = 103,
       Baerentatze = 104,
       Brokwilb = 105,
       Brunnenkresse = 106,
       Chronchinis = 107,
       Eichhase = 108,
       Eisenkraut = 109,
       Goldrute = 110,
       Hexenroehring = 111,
       Hiradwurz = 112,
       Johanniskraut = 113,
       Katzenpfoetchen = 114,
       Koenigskerze = 115,
       Lathan = 116,
       Maultierpollen = 117,
       Merrig = 118,
       Nachtschatten = 119,
       Nebelkappe = 120,
       Pantherpilz = 121,
       Riesenbovist = 122,
       Teufelskraut = 123,
       Teufelszunge = 124,
       Tigerritterling = 125,
       Tintenfischpilz = 126,
       Trudustbluete = 127,
       Weidenroeschen = 128,
       WeisserAndorn = 129,
       Wolfskraut = 130
    };

This will fix the error you post, but this uncovers another error, which is that you are trying to use an uninstantiated class as an object.

If you understand the above sentence, then well and good. You just need to use GetComponent(typeof(Rohstoffe)) on your gameobject to get the Rohstoffe object you work on.

If you don’t understand the sentence about “uninstantiated class” and “object” then you need to do some reading on the basic rules and techniques of Object Orientated Programming. Far too much to fit in an answer here.

Thank you a lot! I do understand what you want to explain, it has been a long time since I coded the last time, but now I remember :slight_smile:
Merry Christmas!