Just a heads Up for backgound

I added UnityEngine.Resources.Load to make it work.

               Rect canvas = GUILayoutUtility.GetRect(canvasSize, canvasSize);
                Texture2D backgroundTex = UnityEngine.Resources.Load("background") as Texture2D;
                Rect texCoords = new Rect(0,0,canvasSize / backgroundSize, canvasSize / backgroundSize);

Resources.Load gave me the error NOt in RPG.Resources namespace.

Here is the full procedure that it is needed in.

        private void OnGUI() 
        {
            if (selectedDialogue == null)
            {
                EditorGUILayout.LabelField("No dialogue selected");
            }
            else
            {
                ProcessEvents();
                //Beginning Scroll View
                scrollPosition = EditorGUILayout.BeginScrollView(scrollPosition);

                Rect canvas = GUILayoutUtility.GetRect(canvasSize, canvasSize);
                Texture2D backgroundTex = UnityEngine.Resources.Load("background") as Texture2D;
                Rect texCoords = new Rect(0,0,canvasSize / backgroundSize, canvasSize / backgroundSize);

                GUI.DrawTextureWithTexCoords(canvas, backgroundTex, texCoords);

                foreach (DialogueNode node in selectedDialogue.GetAllNodes())
                {
                    DrawConnections(node);
                }
                foreach (DialogueNode node in selectedDialogue.GetAllNodes())
                {
                    DrawNode(node);
                }

                EditorGUILayout.EndScrollView();

                //Check if user wanted to create a new child node
                if(creatingNode != null)
                {
                    Undo.RecordObject(selectedDialogue, "Added Dialogue node");
                    selectedDialogue.CreateNode(creatingNode);
                    creatingNode = null;
                }

                if(deletingNode != null)
                {
                    Undo.RecordObject(selectedDialogue, "Deleted Dialogue node");
                    selectedDialogue.DeleteNode(deletingNode);
                    deletingNode = null;
                }
            }


        }

Privacy & Terms