コード例 #1
0
        /// <summary> Called whenever the xNode editor window is updated </summary>
        public override void OnBodyGUI()
        {
            // Attempt to draw a texture as the base color
            if (tex == null)
            {
                tex = new Texture2D(1, 1, TextureFormat.RGBA32, false);
            }
            tex.SetPixel(0, 0, customNodeColor);
            tex.Apply();

            if (drawCustomTexture)
            {
                GUI.DrawTexture(new Rect(0, 0, GetWidth(), GetWidth() * 0.5f), tex, ScaleMode.ScaleAndCrop);
            }

            // Draw the default GUI first, so we don't have to do all of that manually.
            base.OnBodyGUI();

            // `target` points to the node, but it is of type `Node`, so cast it.
            DisplayValue displayValueNode = target as DisplayValue;

            // Get the value from the node, and display it
            object obj = displayValueNode.GetValue();

            if (obj != null)
            {
                EditorGUILayout.LabelField(obj.ToString());
            }

            //// CODE TO CHANGE NODE COLOR
            //customNodeColor = EditorGUILayout.ColorField(customNodeColor);

            // Checkbox to allow the drawing of custom texture
            drawCustomTexture = EditorGUILayout.Toggle("Custom node texture", drawCustomTexture);
        }
コード例 #2
0
        /// <summary> Called whenever the xNode editor window is updated </summary>
        public override void OnBodyGUI()
        {
            // Draw the default GUI first, so we don't have to do all of that manually.
            base.OnBodyGUI();

            // `target` points to the node, but it is of type `Node`, so cast it.
            DisplayValue displayValueNode = target as DisplayValue;

            // Get the value from the node, and display it
            object obj = displayValueNode.GetValue();

            if (obj != null)
            {
                EditorGUILayout.LabelField(obj.ToString());
            }
        }