小编Ste*_*ven的帖子

如何从Facebook Unity SDK获取用户名

我是团结的新手,并试图整合Facebook unity SDK.但我无法找到当前登录的用户名.它只返回userId和accessToken.如何获取登录名FB.Login("email")

social facebook unity-game-engine facebook-graph-api

2
推荐指数
1
解决办法
7375
查看次数

AOP Ninject停止拦截方法被调用

我正在使用Ninject和AOP来做一些缓存.我有一个属性,我可以应用于我的存储库中的任何方法和BeforeInvoke它将返回我的缓存对象,如果有一个和AfterInvoke创建一个缓存的对象.这一切都很好,但我无法弄清楚如何停止调用初始方法,即如果有一个缓存的对象返回而不是调用intyercepted方法.我的拦截器在这里:

public class CacheInterceptor : SimpleInterceptor
{
    protected override void BeforeInvoke(IInvocation invocation)
    {
        Type returnType = invocation.Request.Method.ReturnType;
        string cacheKey = CacheKeyBuilder.GetCacheKey(invocation, serializer);
        object cachedValue = cache.Get(cacheKey);
        if (cachedValue == null)
        {
            invocation.Proceed();
        }
        else
        {
            object returnValue = serializer.Deserialize(returnType, cachedValue);
            invocation.ReturnValue = returnValue;
            returnedCachedResult = true;
        }
     }
}
Run Code Online (Sandbox Code Playgroud)

即使在else语句中我显然没有说要调用被调用的方法'invocation.Proceed();' 它仍然会调用它.如何告诉ninject只返回invocation.ReturnValue?

c# aop ninject interception ninject-interception

2
推荐指数
1
解决办法
610
查看次数

Unity3D - 在真实设备上部署时,图像数量很少

部署统一产品时遇到问题.

作为标题:在真实设备上部署时,我的图像数量很少.这在编辑器上是正常的

我正在使用Mac OSX 10.8,Unity 4.2.1并构建到iOS版本

请让我知道如何解决这个问题.

谢谢!

unity-game-engine

2
推荐指数
1
解决办法
703
查看次数

在Android上运行时写入Unity的StreamingAssets文件夹?

所以......我的目标如下:

  1. 使用http请求下载.mp4视频.
  2. 使用www.bytes和File.WriteAllBytes()将它放在Android APK的StreamingAssets文件夹中.
  3. 使用我购买的EasyMovieTexture电影插件在Android设备上播放.

但是,当我尝试写入StreamingAssets文件夹时,我遇到错误,位于以下路径:

jar:file:///data/app/com.catlard.testName-1.apk!/assets/ash.mp4
Run Code Online (Sandbox Code Playgroud)

这也是下面PlaceMovieInStreamingAssets函数中_debugString的第一个值.甚至可以在Android上运行时写入StreamingAssets文件夹吗?这是我用来做这些东西的课程.它在WriteAllBytes调用中停止 - 我知道,因为我在前后放置了print语句,而这就是它停止的地方.

using UnityEngine;
using System.Collections;
using System.IO;

public class StartVideoFromWeb : MonoBehaviour {

    public string _movieFileName;
    public string _movieHTTPLocation;
    private string _debugString;
    private MediaPlayerCtrl _control;
    public float _mbFileSize = 16.7f;
    private string _movieLocationOnDevice;

    private float _prevProg;

    private WWW _movieWWW;

    public float _kbSpeed;
    public float _timeBetweenSpeedMeasurements = 1f;

    // Use this for initialization

    public IEnumerator Start() {

       yield return StartCoroutine("LoadMovie");
       PlaceMovieInStreamingAssets(_movieWWW);
       yield return new WaitForSeconds(.5f);
       //PlayMovieInCtrl(_movieHTTPLocation + _movieFileName);
       PlayMovieInCtrl(_movieLocationOnDevice);

       yield return 0; …
Run Code Online (Sandbox Code Playgroud)

video android unity-game-engine

2
推荐指数
2
解决办法
1万
查看次数

如何在Unity 2D中创建白色矩形?

Hello Stack Overflow社区.

我刚刚开始使用Unity将我的视频游戏移植到多个平台.我有一个关于在Unity中以编程方式创建对象的问题.这就是我目前的游戏:

在此输入图像描述

当用户点击相机按钮时,相机图片在Tap和offTap上缩放得更大.我希望整个屏幕只闪一分钟,但我不知道如何做到这一点.这是我已经针对这个问题的C#代码:

using UnityEngine;
using System.Collections;

public class question3 : MonoBehaviour {
    int cameraTaps = 0;
    // Use this for initialization
    void Start () {

    }

    IEnumerator CameraCoroutine() {
        Debug.Log("Before Waiting 3 seconds");
        yield return new WaitForSeconds(3);
        Debug.Log("After Waiting 3 Seconds");
        Application.LoadLevel("question4");
    }
    // Update is called once per frame
    void Update () {
        if (Input.GetMouseButtonDown(0)) 
        {
            RaycastHit hit;
            Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);

            if (Physics.Raycast(ray, out hit))
            {
                if (hit.collider.gameObject.name == "camera")
                {
                    var camera …
Run Code Online (Sandbox Code Playgroud)

c# android unity-game-engine ios

2
推荐指数
1
解决办法
1万
查看次数

Unity3D localscale问题

如下代码:

Debug.LogWarning("updating scale fix, scalefactor: "+scaleFactor+" - Current scale is: "+cell.transform.localScale.x);
cell.transform.localScale.Set (scaleFactor,scaleFactor,scaleFactor);
Debug.LogWarning("Scale after fix: " + cell.transform.localScale.x);
Run Code Online (Sandbox Code Playgroud)

产生以下输出:

updating scale fix, scalefactor: 0.9 - Current scale is 0.8921105
UnityEngine.Debug:LogWarning(Object)

Scale after fix: 0.8921105
UnityEngine.Debug:LogWarning(Object)
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?我只是假设由于这些事情是紧接着发生的,因此应该更新规模。还是在框架完成之后发生?

任何帮助表示赞赏。

c# transform scale unity-game-engine

2
推荐指数
1
解决办法
7843
查看次数

在Unity中闪烁游戏对象

如何使用SetActiveRecursively(Moment = 1秒)在Unity中创建闪烁对象.

我的例子(改变):

public GameObject flashing_Label;

private float timer;

void Update() {

while(true)
{
flashing_Label.SetActiveRecursively(true);
timer = Time.deltaTime;

  if(timer > 1)       
          {
            flashing_Label.SetActiveRecursively(false);
            timer = 0;        
          }   
 }

}
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine ngui unityscript

2
推荐指数
1
解决办法
9556
查看次数

删除Convert.ToDecimal依赖(依赖注入)

我目前正在学习依赖注入,以便使用MVC创建更易于维护的代码.我已经向我的控制器注入模型和计算器服务,而不是具有新的依赖性.

我在构造函数中有一些Convert.ToDecimal调用,并且不知道是否需要担心使用依赖注入来移除静态方法调用,这是一种DI设计气味.删除太远了吗?

private readonly ICalculationService _calculation;
private readonly ICalculatorModelService _calculatormodel;

public CalculatorController(ICalculationService calculation,
    ICalculatorModelService calculatormodel) {
    _calculation = calculation;
    _calculatormodel = calculatormodel;
}

public ActionResult Index() {
    var model = _calculatormodel;
    return View(model);
}

public PartialViewResult Calculate(string submit, string txtValue, 
    string value1) {
    var model = _calculatormodel;
    if (submit == "+")
    {
        if (Session["value1"] == null)
            Session.Add("value1",Convert.ToDecimal(txtValue));
        else
            Session["value1"] = value1;
    }
    else if (submit == "=")
    {
        if (Session["value1"] == null)
        Session.Add("value1", 0);

        model.Result = _calculation.Calculate(Convert
            .ToDecimal(Session["value1"]), Convert.ToDecimal(txtValue));
    } …
Run Code Online (Sandbox Code Playgroud)

c# dependency-injection solid-principles

2
推荐指数
1
解决办法
80
查看次数

使用 Simple Injector 注册集合

我尝试在 c# 中使用简单的注入器注册一个集合。我的方法如下:

container.Collection.Register<IValidateMitarbeiter>(
    typeof(MitarbeiterVerfuegbarkeitValidator),
    typeof(MitarbeiterQualifikationsValidator));
Run Code Online (Sandbox Code Playgroud)

但我收到此错误消息:

配置无效。创建 IDispoLinienManager 类型的实例失败。DispoLinienManager 类型的构造函数包含名称为“mitarbeiterValidators”且类型为 IValidateMitarbeiter 的未注册参数。请确保 IValidateMitarbeiter 已注册,或更改 DispoLinienManager 的构造函数。

这是 DispoLinienManager 的构造函数

public DispoLinienManager(IDataContextFactory dataContextFactory,
        IDispoPlanLinieFactory dispoPlanLinieFactory,
        IValidateMitarbeiter mitarbeiterValidators)
    {
        this.dataContextFactory = dataContextFactory;
        this.dispoPlanLinieFactory = dispoPlanLinieFactory;
        this.mitarbeiterValidators = mitarbeiterValidators;
    }
Run Code Online (Sandbox Code Playgroud)

IValidateMitarbeiter 有两个实现,它们都在 DispoLinienManager 中使用。如果有任何遗漏的信息,我将很乐意帮助您解决我的问题。

c# dependency-injection simple-injector

2
推荐指数
1
解决办法
3388
查看次数

将实体框架核心DbContext池与简单注入器一起使用

查看有关如何使用数据库上下文池的示例,我发现它是设计用于ServiceCollection

var serviceProvider = new ServiceCollection()
    .AddDbContextPool<AdventureWorksContext>(options => { //options })
    .BuildServiceProvider();
Run Code Online (Sandbox Code Playgroud)

但是简单注入器呢?是否可以在Simple Injector容器中注册数据库池?

ps我的应用不是ASP.NET MVC,只是DAL

simple-injector dbcontext entity-framework-core ef-core-2.1

2
推荐指数
2
解决办法
1672
查看次数