欧美日批视频_伊人影院焦久影院_午夜精品一区二区三区视频免费看_自拍偷拍视频在线观看_日本一线在线观看_毛片免费观看完整版

  • 您的位置:首頁 > 新聞動態 > 技術文章

    UE4實現簡單的插件開發VS2015

    2017/8/8??????點擊:

    1. 從Editor中生成一個空的C++插件模板

    2. 關掉vs,右鍵生成一下工程文件,把Plugins掃進去

    打開解決方案開始編寫插件,插件加進來了 

    3. 編寫插件
    首先把插件的配置文TestPlugin.uplugin件改一下(被這個坑了兩天) 
    這個LoadingPhase的值默認為Default,必須修改為PreDefault,不然重啟Editor會報關聯不上插件源碼的錯誤,切記! 


    修改編譯模塊配置TestPlugin.Build.cs文件,c#文件 


    詳細代碼,有注釋 !
    using UnrealBuildTool;
    using System.IO; //路徑獲取需要用到IO
    public class TestPlugin : ModuleRules
    {
        private string ModulePath //當前TestPlugin.Build.cs文件所在的路徑
        {
            get { return Path.GetDirectoryName(RulesCompiler.GetModuleFilename(this.GetType().Name)); }
        }
        private string ThirdPartyPath //這個插件引用的第三方庫的目錄
        {
            get { return Path.GetFullPath(Path.Combine(ModulePath, "../../ThirdParty/")); }
        }
        private string MyTestLibPath //第三方庫MyTestLib的目錄
        {
            get { return Path.GetFullPath(Path.Combine(ThirdPartyPath, "MyTestLib")); }
        }
        public TestPlugin(TargetInfo Target)
        {
            PublicIncludePaths.AddRange( //公有文件搜索路徑
                new string[] {
                    "TestPlugin/Public"
                    // ... add public include paths required here ...
                }
                );
            PrivateIncludePaths.AddRange(
                new string[] {
                    "TestPlugin/Private" //私有文件搜索路徑
                    // ... add other private include paths required here ...
                }
                );
            PublicDependencyModuleNames.AddRange(
                new string[]
                {
                    "Core"
                    // ... add other public dependencies that you statically link with here ...
                }
                );
            PrivateDependencyModuleNames.AddRange(
                new string[]
                {
                    "CoreUObject",
                    "Engine",
                    "Slate",
                    "SlateCore",
                    // ... add private dependencies that you statically link with here ...  
                }
                );
            DynamicallyLoadedModuleNames.AddRange(
                new string[]
                {
                    // ... add any modules that your module loads dynamically here ...
                }
                );
            LoadThirdPartyLib(Target); //加載第三方庫
        }
        public bool LoadThirdPartyLib(TargetInfo Target)
        {
            bool isLibrarySupported = false;
            if ((Target.Platform == UnrealTargetPlatform.Win64) || (Target.Platform == UnrealTargetPlatform.Win32))//平臺判斷
            {
                isLibrarySupported = true;
                System.Console.WriteLine("----- isLibrarySupported true");
                string PlatformSubPath = (Target.Platform == UnrealTargetPlatform.Win64) ? "Win64" : "Win32";
                string LibrariesPath = Path.Combine(MyTestLibPath, "Lib");
                PublicAdditionalLibraries.Add(Path.Combine(LibrariesPath, PlatformSubPath, "TestLib.lib"));//加載第三方靜態庫.lib
            }
            if (isLibrarySupported) //成功加載庫的情況下,包含第三方庫的頭文件
            {
                // Include path
                System.Console.WriteLine("----- PublicIncludePaths.Add true"); 
                PublicIncludePaths.Add(Path.Combine(MyTestLibPath, "Include"));
            }
            return isLibrarySupported;
        }
    }

    我們寫個自定義的char – TestChar,繼承自Character 
    先看下文件結構,需要藍圖可見的必須丟到Public下 


    先修改預編譯頭文件TestPluginPrivatePCH.h,必須包含CoreUObject,不然編譯不過,切記!
    #include "TestPlugin.h"
    // UObject core
    #include "CoreUObject.h" //默認是不含這個的
    // Actor based classes
    #include "GameFramework/Character.h" //包插件中所有用的的引擎類都丟到這里來


    頭文件,正常編寫自定義的類一樣
    #pragma once
    #include "GameFramework/Character.h"
    #include "TestChar.generated.h"
    UCLASS()
    class ATestChar : public ACharacter
    {
        GENERATED_BODY()
    public:
        // Sets default values for this character\'s properties
        ATestChar();
        UPROPERTY(EditAnywhere, Category = "Test Char")
            int32           mAge;
        UPROPERTY(EditAnywhere, Category = "Test Char")
            FString         mName;
    };

    cpp文件,包含的是預編譯文件和類的頭文件
    #include "TestPluginPrivatePCH.h"
    #include "TestChar.h"
    #include "TestLib.h" //引入的第三方庫的頭文件
    ATestChar::ATestChar() : Super()
    {
        mAge = myPrint("hello world", 123); //第三方庫中的方法
        mName = "yangx";
    }

    第三方庫打成了一個靜態庫TestLib.lib
    TestLib.h
    #ifndef __TEST_LIB_H__
    #define __TEST_LIB_H__
    #include
    #include
    int myPrint(std::string _name, int _age);
    #endif

    TestLib.cpp
    #include "TestLib.h"
    int myPrint(std::string _name, int _age)
    {
        return _age + 1000;
    }

    4. 編譯運行,在Editor中create一個Blueprint繼承自這個TestChar類


    5. 拖到場景運行游戲

    6.WONGLOVE數據手套的UE4插件類似于上述方法, 如果您是WONGLOVE用戶,可以聯系我們索取該插件程序。


    主站蜘蛛池模板: 蜜臀av午夜一区二区三区 | 妇欲欢公爽婷婷在线观看 | 国产精品禁18久久久夂久 | 一区二区三区精液 | 国产99久久精品一区二区永久免费 | 国产97色在线 | 高清久久久久久 | 亚洲欧美第一 | 99久热re在线精品99 6热视频 | 第一精品福利 | 亚洲色无码a片一区二区红樱 | 国产三级视频 | "www 五月天 com" | 办公室撕开奶罩揉吮奶在线观看 | 久久精品国产网址 | 亚洲综合AV在线在线播放 | 国产精品久久久久久久久久久久午夜片 | 国产亚欧美一区二区三区奶水 | 亚洲综合一区在线观看 | 小早川怜子一区二区的演员表 | 久久久久久三区 | 国产无套露脸视频在线观看 | V一区无码内射国产 | 亚洲性综合网 | ru继nv娇小h 久久免费精品一区二区三区 | 午夜蜜桃视频 | 公主荫蒂每天被男人添H | 国产精品久久久久久久四虎电影 | 惊弦2023连续剧免费观看孙红雷 | 美女免费黄视频网站 | 国产精品video爽爽爽爽 | 国产成人手机高清在线观看网站 | 狠色狠色狠狠色综合久久 | 中国xxxxxx片免费播放 | 91超碰在线播放 | 国产中文精品久高清在线不 | 免费性爱视频 | 欧美久久综合 | 成人你懂的网站 | 麻豆av高清 | www.av一区 |