2021-08-11 independent game development log - development environment, project initialization, etc.

Posted by ntnwwnet on Fri, 24 Dec 2021 03:57:20 +0100

Development environment:

Unity engine: April 2019 29f1c1

Development toolset: Visual Studio 2019

Plug in: Visual AssistX

Version control:

                Gitee

                TortoiseGit

                SourceTree

Create a Gitee library.

Use SourceTree to associate local paths.

Create the Unity project under the local association path.

Customize the development page layout under the Unity editor.

Directory level for creating Code:

C # framework (u c)

Unity framework

                Editor

                Runtime

Unity framework supplement (framework__s)

Main logic

Main logic supplement (MainLogic_s)

Create a delegate that encapsulates a method that has no return value.

The usage method is shown in the following code segment:

// Create a delegate type that encapsulates a method with one parameter and no return value.
public delegate void FrameworkAction<in T>(T obj);

// Declare an instance of the delegate type.
public FrameworkAction<DownloadAgent> DownloadAgentStart;

// A method to load into the delegate instance.
private void OnDownloadAgentStart(DownloadAgent sender)
{
    if (m_DownloadStartEventHandler != null)
    {
        DownloadStartEventArgs downloadStartEventArgs =                        DownloadStartEventArgs.Create(sender.Task.SerialId, sender.Task.DownloadPath,                sender.Task.DownloadUri, sender.CurrentLength, sender.Task.UserData);
        m_DownloadStartEventHandler(this, downloadStartEventArgs);
        ReferencePool.Release(downloadStartEventArgs);
    }
}

// Load method in delegate instance.
agent.DownloadAgentStart += OnDownloadAgentStart;

// The method that executes this delegate load.
public StartTaskStatus Start(DownloadTask task)
{
    ...
    if (DownloadAgentStart != null)
    {
        DownloadAgentStart(this);
    }
    ...
}

Create a delegate that encapsulates a method that has a return value.

The use method is shown in the code snippet below.

// Create a delegate that encapsulates the method. The delegate has two parameters and a return value of TResult type.
public delegate TResult GameFrameworkFunc<in T1, in T2, out TResult>(T1 arg1, T2 arg2);

// Declare an instance of the delegate.
public event GameFrameworkFunc<string, float, bool> ProcessingAssetBundle = null;

// The method that the delegate will load.
private bool OnProcessingAssetBundle(string assetBundleName, float progress)
{
        if (EditorUtility.DisplayCancelableProgressBar("Processing AssetBundle", Utility.Text.Format("Processing '{0}'...", assetBundleName), progress))
        {
            EditorUtility.ClearProgressBar();
            return true;
        }
    else
    {
        Repaint();
        return false;
    }
}

// Load method in delegate instance.
m_Controller.ProcessingAssetBundle += OnProcessingAssetBundle;

// The method that executes this delegate load.
...
if (ProcessingAssetBundle != null)
{
    if (ProcessingAssetBundle(fullName, (float)(i + 1) / assetBundleResourceDatas.Length))
    {
            ...
    }
}
...

Add a utility Text.

Used to get the formatted splice string.

Add a utility Assembly class.

Class used to get the specified class name in the assembly.

Customize a FrameworkException class that overrides the Exception class.

The user-defined exception class is different from the standard exception class of System. It is mainly used to mark the abnormal event flow in business logic and avoid confusion with the standard exception in System.

Add a FrameworkComponent class.

The abstract base class of framework components. All components used in applications should inherit from this class.

Add a FrameworkEntry class.

This is a static class and the entry class of the framework. All components should call the registered component methods in this class and cache themselves in a component list of LinkedList < frameworkcomponent >.

The FrameworkComponent class invokes the registration component method in the framework entrance class in the Awake method, and registers itself.

Add a BaseComponent.

Applied in unityengine DLL reference some of the underlying initialization and setting work.

Implement log module logic.

FrameworkLogLevel: enumeration of log levels, including debug, info, warning, error and fatal.

ILogHelper: log helper interface.

FrameworkLog: Framework log class.

DefaultLogHelper: the default log helper. A class that implements the logic of printing journals.

Initialize the log assistant in the basic component under the U framework.

Add the Log class under the Tool directory under the U framework, which is used to specifically call the Log assistant to print logs.

Add script macro definition class and standardize mode.

The script macro definition class of switching log is added to switch the log printing logic of each level.

Topics: C# Game Development Unity3d