Search Unity

Feedback Advice for Unity to win over more Users and more money

Discussion in 'General Discussion' started by DrPTF, May 20, 2020.

  1. DrPTF

    DrPTF

    Joined:
    May 14, 2020
    Posts:
    11
    Hi Unity Staff,

    I wasted another day trying to learn through the tutorial Creator Kit - Beginner Code only to get stuck at the end with multiple errors in official code. Then, I found out that the tutorial is meant for Unity 2019.2 and I have the latest 2019.3.14f1 installed. I didn't expect that a .1 difference in versions to render beginner tutorials obsolete. I searched again for the beginner tutorials for 2019.3 and found none that is systematic. Maybe I joined the Unity game development at the wrong time?

    I have seen your rivalry with Unreal Engine, and my sincere advice for you is: you need to return to your roots. Your business model rests on helping amateur developers grow into professionals whose game can win money, win big money, and on collecting royalties for program use. Therefore, the faster you can help amateurs win big money through their games, the faster you are going to reap profit. Thanks to Covid-19, many people lost their jobs. If you can capture the market and provide self employment for jobless people, you are going to sweep the market like a tsunami.

    More concretely, I want to see Unity polishing existing assets and packages so that even the latest version of Unity can use them. I also want to see all the common functions (menu, loading screen, settings, cash shop, inventory, character stat, character editing, save/load, multiplayer/networking, security, etc) of a money-winning game built into coherent modules with clear and working instructions on how to put them together.

    Thanks and hope to see improvements in the near future. After all, we don't have unlimited money while out of job.
     
    IllTemperedTunas likes this.
  2. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Hi there! May we see which errors you've encountered at the end of the tutorial? Maybe we can help. It does sound a bit weird that a .1 difference causes a breaking change.
     
  3. DrPTF

    DrPTF

    Joined:
    May 14, 2020
    Posts:
    11
    When I try to use the menu function Beginner Code > Create Item Effect, I get this error in console:

    NullReferenceException: Object reference not set to an instance of an object
    at NameWindow.OnGUI () [0x0005e] in C:\Users\ABCD\AppData\Local\Temp\d494279a4ef16ca4fa01120f344d41f6\Assets\Creator Kit - Beginner Code\Scripts\Editor\CreateScriptEditor.cs:178

    When I try to use the official code that the menu is supposed to create:

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;

    public class AddHealthEffect : UsableItem.UsageEffect
    {
    public override bool Use(CharacterData user)
    {
    return false;
    }
    }

    I get these errors:

    Assets\Creator Kit - Beginner Code\Scripts\AddHealthEffect.cs(5,32): error CS0246: The type or namespace name 'UsableItem' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Creator Kit - Beginner Code\Scripts\AddHealthEffect.cs(7,30): error CS0246: The type or namespace name 'CharacterData' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Creator Kit - Beginner Code\Scripts\AddHealthEffect.cs(7,26): error CS0115: 'AddHealthEffect.Use(CharacterData)': no suitable method found to override
     
  4. IgnisIncendio

    IgnisIncendio

    Joined:
    Aug 16, 2017
    Posts:
    223
    Do you have a script at Assets\Creator Kit - Beginner Code\Scripts\Items\UsableItem.cs?
     
  5. DrPTF

    DrPTF

    Joined:
    May 14, 2020
    Posts:
    11
    I do. Here is the code in it.

    using System.Collections;
    using System.Collections.Generic;
    using CreatorKitCode;
    using UnityEngine;
    using System.Linq;

    #if UNITY_EDITOR

    using UnityEditor;

    #endif

    namespace CreatorKitCode {

    /// <summary>


    /// Describe an usable item. A usable item is an item that can be used in the inventory by double clicking on it.


    /// When it is used, all the stored UsageEffects will be run, allowing to specify what that item does.


    /// (e.g. a AddHealth effect will give health point back to the user)


    /// </summary>


    [CreateAssetMenu(fileName = "UsableItem", menuName = "Beginner Code/Usable Item", order = -999)]

    public class UsableItem : Item


    {

    public abstract class UsageEffect : ScriptableObject


    {

    public string Description;

    //return true if could be used, false otherwise.


    public abstract bool Use(CharacterData user);


    }

    public List<UsageEffect> UsageEffects;

    public override bool UsedBy(CharacterData user)


    {

    bool wasUsed = false;

    foreach (var effect in UsageEffects)


    {

    wasUsed |= effect.Use(user);

    }



    return wasUsed;


    }

    public override string GetDescription()


    {

    string description = base.GetDescription();




    if(!string.IsNullOrWhiteSpace(description))

    description += "\n";

    else


    description = "";




    foreach (var effect in UsageEffects)


    {

    description += effect.Description + "\n";


    }

    return description;


    }

    }

    }

    #if UNITY_EDITOR

    [CustomEditor(typeof(UsableItem))]

    public class UsableItemEditor : Editor

    {

    UsableItem m_Target;



    ItemEditor m_ItemEditor;

    List<string> m_AvailableUsageType;

    SerializedProperty m_UsageEffectListProperty;



    void OnEnable()

    {

    m_Target = target as UsableItem;

    m_UsageEffectListProperty = serializedObject.FindProperty(nameof(UsableItem.UsageEffects));



    m_ItemEditor = new ItemEditor();

    m_ItemEditor.Init(serializedObject);

    var lookup = typeof(UsableItem.UsageEffect);

    m_AvailableUsageType = System.AppDomain.CurrentDomain.GetAssemblies()

    .SelectMany(assembly => assembly.GetTypes())

    .Where(x => x.IsClass && !x.IsAbstract && x.IsSubclassOf(lookup))

    .Select(type => type.Name)

    .ToList();

    }

    public override void OnInspectorGUI()

    {

    m_ItemEditor.GUI();



    int choice = EditorGUILayout.Popup("Add new Effect", -1, m_AvailableUsageType.ToArray());

    if (choice != -1)

    {

    var newInstance = ScriptableObject.CreateInstance(m_AvailableUsageType[choice]);



    AssetDatabase.AddObjectToAsset(newInstance, target);



    m_UsageEffectListProperty.InsertArrayElementAtIndex(m_UsageEffectListProperty.arraySize);

    m_UsageEffectListProperty.GetArrayElementAtIndex(m_UsageEffectListProperty.arraySize - 1).objectReferenceValue = newInstance;

    }

    Editor ed = null;

    int toDelete = -1;

    for (int i = 0; i < m_UsageEffectListProperty.arraySize; ++i)

    {

    EditorGUILayout.BeginHorizontal();

    EditorGUILayout.BeginVertical();

    var item = m_UsageEffectListProperty.GetArrayElementAtIndex(i);

    SerializedObject obj = new SerializedObject(item.objectReferenceValue);

    Editor.CreateCachedEditor(item.objectReferenceValue, null, ref ed);



    ed.OnInspectorGUI();

    EditorGUILayout.EndVertical();

    if (GUILayout.Button("-", GUILayout.Width(32)))

    {

    toDelete = i;

    }

    EditorGUILayout.EndHorizontal();

    }

    if (toDelete != -1)

    {

    var item = m_UsageEffectListProperty.GetArrayElementAtIndex(toDelete).objectReferenceValue;

    DestroyImmediate(item, true);



    //need to do it twice, first time just nullify the entry, second actually remove it.

    m_UsageEffectListProperty.DeleteArrayElementAtIndex(toDelete);

    m_UsageEffectListProperty.DeleteArrayElementAtIndex(toDelete);

    }

    serializedObject.ApplyModifiedProperties();

    }

    }

    #endif
     
  6. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    You need to add:
    Code (CSharp):
    1. using CreatorKitCode;
    at the top of your file, since UsableItem is in the CreatorKitCode namespace
     
  7. DrPTF

    DrPTF

    Joined:
    May 14, 2020
    Posts:
    11
    Thanks, this finally works. They hid the upper part of the code in subsequent steps on purpose huh? And no hint to help tired brain. The menu function still gives error, so I'm supposed to dig deeper in the script?

    There was the other kit, The Explorer: 3D Game Kit, which throws 999+ errors on first run right after downloading. Is there a trick for that too?

    I understand that coding can be very frustrating at times, but please don't design your tutorials to frustrate beginners. Keeping silent and waiting student to dig without clear hint, especially for beginners, is a detestable way of education.
     
  8. Ryiah

    Ryiah

    Joined:
    Oct 11, 2012
    Posts:
    21,190
    Unity's versioning system is not a normal versioning system. Prior to 2020 that .1 release would have been anywhere from three to four months (one-third of the year), but starting with 2020 that .1 release is about six months (one-half of the year).

    tech_lts-flowchart-horizontal.png

    tech_lts-flowchart-horizontal-4-1280x720.png
     
    Last edited: May 20, 2020
  9. DrPTF

    DrPTF

    Joined:
    May 14, 2020
    Posts:
    11
    @Ryiah Thanks for the explanation.

    Continuing about the Beginner Code menu:

    I have looked at the CreateScriptEditor.cs, and it looks like it would find Sample files, rename, create path, refresh AssetDatabase etc. But there is no said sample files in the folders, and it didn't create any folder. I don't understand what is wrong at the line 178 either.