Runtime representation of the AnimatorController. It can be used to change the Animator's controller during runtime.

Inheritance: Object
Example #1
1
	public MechCreator(string c, List<string> p) {
		coreName = c;
		core = Resources.Load(c, typeof(GameObject)) as GameObject;
		if (core == null ) {
			Debug.Log("null core, using default");
			core = Resources.Load(defaultCore, typeof(GameObject)) as GameObject;
			coreName = defaultCore;
		}
		parts = new List<GameObject>();

		if (p == null || p.Capacity == 0) {
			Debug.Log("null parts, using default");
			for (int i = 0; i < defaultParts.Length; i++) {
				GameObject part = Resources.Load(defaultParts[i], typeof(GameObject)) as GameObject;
				parts.Add(part);
			}
		} else {
			for (int i = 0; i < p.Count; i++) {
				GameObject part = Resources.Load(p[i], typeof(GameObject)) as GameObject;
				if (part == null ) part = Resources.Load(defaultParts[i], typeof(GameObject)) as GameObject;
				parts.Add(part);
			}
		}

		animator = Resources.Load("ThirdAnimator", typeof(RuntimeAnimatorController)) as RuntimeAnimatorController; if (animator == null )Debug.Log("animator");
		mechCam = Resources.Load("MechCam", typeof(GameObject)) as GameObject; if (mechCam == null )Debug.Log("MechCam");
		radar = Resources.Load("Radar", typeof(GameObject)) as GameObject; if (radar == null )Debug.Log("Radar");
		stitcher = new Stitcher();
	}
 static public int constructor(IntPtr l)
 {
     UnityEngine.RuntimeAnimatorController o;
     o = new UnityEngine.RuntimeAnimatorController();
     pushObject(l, o);
     return(1);
 }
Example #3
0
    static int _CreateUnityEngine_AnimatorOverrideController(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 0)
            {
                UnityEngine.AnimatorOverrideController obj = new UnityEngine.AnimatorOverrideController();
                ToLua.Push(L, obj);
                return(1);
            }
            else if (count == 1)
            {
                UnityEngine.RuntimeAnimatorController  arg0 = (UnityEngine.RuntimeAnimatorController)ToLua.CheckObject <UnityEngine.RuntimeAnimatorController>(L, 1);
                UnityEngine.AnimatorOverrideController obj  = new UnityEngine.AnimatorOverrideController(arg0);
                ToLua.Push(L, obj);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to ctor method: UnityEngine.AnimatorOverrideController.New"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
	// note: ProjectileContainers contain simple dummy values, which are
	// then replaced by data that's passed-in via projectile objects
	void Init(Weapon incoming)
	{
		weapon                = incoming;
		weaponType            = incoming.weaponType;
		alreadyCollided       = false;
		iconSprite            = incoming.iconSprite;
		title                 = incoming.title;
		damage                = incoming.damage;
		hp                    = incoming.hp;
		rateOfAttack          = incoming.rateOfAttack;
		spriteRenderer.sprite = incoming.carriedSprite;
		speed                 = incoming.speed;
		maxDistance           = incoming.maxDistance;
		lob                   = incoming.lob;
		lobGravity            = incoming.lobGravity;
		fadeIn                = incoming.fadeIn;
		collider2D.enabled    = true;
		origin                = new Vector3(transform.position.x, transform.position.y, transform.position.z);

		// initialize animation controller if projectile is animated
		if (incoming.GetComponent<Weapon>().animatedProjectile)
		{
			anim = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate
						(Resources.Load(("Sprites/Projectiles/" + incoming.name + "_0"), typeof(RuntimeAnimatorController)));
			animator.runtimeAnimatorController = anim;
			animator.speed = .5f;
		}

		InvokeRepeating("CheckDistanceTraveled", 1, 0.3F);
	}
Example #5
0
    public void iniciate(Vector2 dir, Vector2 pos, RuntimeAnimatorController animController, float bulletSpd, int dmg, string weapon)
    {
        damage = dmg;
        direction = new Vector2(dir.x, dir.y);
        bulletSpeed = bulletSpd;

        if (dir == Vector2.up){
            transform.position = pos + new Vector2(0.1f, 0.35f);
            transform.rotation = Quaternion.Euler(0, 0, 90);
        }
        else if (dir == Vector2.down) {
            transform.position = pos + new Vector2(-0.1f, -0.75f);
            transform.rotation = Quaternion.Euler(0, 0, 90);
        }
        else{
            transform.position = pos + new Vector2(direction.normalized.x*0.5f, -0.17f);
            transform.rotation = Quaternion.Euler(0, 0, 0);
        }
        animator = GetComponent<Animator>();
        animator.runtimeAnimatorController = animController;

        animator.SetBool("explode", false);
        //load hitSound

        string soundLoaderString = "Sounds/Weapon/";
        string hitSoundString = weapon + "Hit";

        if(Resources.Load(soundLoaderString + hitSoundString) != null)
            hitSound = Resources.Load(soundLoaderString + hitSoundString) as AudioClip;

        gameObject.SetActive(true);
        isActive = true;
    }
    static int LoadAnimatorController(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 1)
            {
                string arg0 = ToLua.CheckString(L, 1);
                UnityEngine.RuntimeAnimatorController o = ShibaInu.ResManager.LoadAnimatorController(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2)
            {
                string arg0 = ToLua.CheckString(L, 1);
                string arg1 = ToLua.CheckString(L, 2);
                UnityEngine.RuntimeAnimatorController o = ShibaInu.ResManager.LoadAnimatorController(arg0, arg1);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: ShibaInu.ResManager.LoadAnimatorController"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
	public AnimationExportData (Transform transform, bool useQuaternion)
	{
		t = transform;

		Animator ator = t.GetComponent<Animator>();

		a = ator.runtimeAnimatorController;

		defaultAnimation = a.animationClips[0];

		AnimationClipCurveData[] data = AnimationUtility.GetAllCurves (defaultAnimation, true);
		properties = new Hashtable();

		foreach (AnimationClipCurveData d in data) {
			
			string jn = AnimationUtil.ExtractPropertyName (d.propertyName);

			if(!properties.ContainsKey (d.path))
				properties.Add(d.path, new AnimationObject(d.path));

			AnimationObject ao = (AnimationObject) properties[d.path];

			AnimationProperty p = new AnimationProperty (jn, d);
			ao.Properties.Add(p);
		}
	}
 static public int get_animationClips(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         UnityEngine.RuntimeAnimatorController self = (UnityEngine.RuntimeAnimatorController)checkSelf(l);
         pushValue(l, true);
         pushValue(l, self.animationClips);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
	public void FillParameterArray(RuntimeAnimatorController animator,AnimatorControllerParameterType type){
		AnimatorController animatorController = animator as AnimatorController;
		List<string> parameterNames = new List<string> ();
		if (animatorController.parameterCount > 0) {
			for (int i=0; i< animatorController.parameterCount; i++) {
				if (animatorController.GetParameter (i).type == type) {
					parameterNames.Add (animatorController.GetParameter (i).name);
				}
			}
			switch(type){
			case AnimatorControllerParameterType.Bool:
				boolNames = parameterNames.ToArray ();
				break;
			case AnimatorControllerParameterType.Float:
				floatNames = parameterNames.ToArray ();
				break;
			case AnimatorControllerParameterType.Int:
				intNames = parameterNames.ToArray ();
				break;
			case AnimatorControllerParameterType.Trigger:
				triggerNames = parameterNames.ToArray ();
				break;
				
			}
		}
	}
Example #10
0
    void Awake()
    {
        // create empty(transform only) game object in scene with default position (0,0,0)
        GameObject myObj = new GameObject();
        myObj.transform.position = new Vector3(0, 3, 0);
        // add sprite renderer component
        myObj.AddComponent<SpriteRenderer>();

        // create texture from resource file
        myTexture = Resources.Load<Texture2D>("ProceduralSprite/100_px") as Texture2D;

        // A) store sprite > store component > assign spite to component property
        mySprite = Sprite.Create(myTexture, new Rect(25,25,75,75), new Vector2(0f, 0f));
        SpriteRenderer myObjComponent = myObj.GetComponent<SpriteRenderer>();
        myObjComponent.sprite = mySprite;

        // B) direct assign
        // myObj.GetComponent<SpriteRenderer>().sprite = Sprite.Create(myTexture, new Rect(0, 0, myTexture.width, myTexture.height), new Vector2(0.5f, 0f));

        // 1)----
        // load previously created animator controller as runtimeAnimationConroller
        myRTimeAnimator = Resources.Load<RuntimeAnimatorController>("ProceduralSprite/Cube") as RuntimeAnimatorController;
        // add animator component to GO and assign animator controller
        myObj.AddComponent<Animator>();
        myObj.GetComponent<Animator>().runtimeAnimatorController = myRTimeAnimator;

        // 2)----
        // alternative way (direct assing)
        // myObj.AddComponent<Animator>();
        // myObj.GetComponent<Animator>().runtimeAnimatorController = Resources.Load<RuntimeAnimatorController>("ProceduralSprite/Cube") as RuntimeAnimatorController;

    }
Example #11
0
 void Start()
 {
     playerAnimator = GetComponentInChildren<Animator>();
     if (!playerAnimator) {
         Debug.LogError(string.Format("Error starting PlayerHealth for {0}: Player doesn't have an animator attached", name));
     }
     originalController = playerAnimator.runtimeAnimatorController;
 }
Example #12
0
        static string Generate(
            Controller controller,
            string namespaceName,
            string className,
            AccessModifier accessModifier,
            bool isPartial
            )
        {
            var parameters = GetParameters(controller);
            var indent     = 0;

            if (className == null)
            {
                className = ClassName(controller);
            }
            var hasNamespace = !string.IsNullOrWhiteSpace(namespaceName);

            var sb = new StringBuilder();

            sb.Append(GeneratedWarning);
            BlankLine(sb);
            AddImports(
                sb,
                ref indent,
                nameof(System),
                nameof(UnityEngine),
                $"{nameof(ParameterType)} = UnityEngine.AnimatorControllerParameterType"
                );
            BlankLine(sb);
            if (hasNamespace)
            {
                OpenNamespace(sb, ref indent, namespaceName);
            }
            {
                OpenClass(sb, ref indent, className, isPartial, isPartial ? null : "MonoBehaviour");
                {
                    AddConstants(sb, ref indent, parameters);
                    BlankLine(sb);
                    AddAnimatorField(sb, ref indent, accessModifier);
                    BlankLine(sb);
                    AddStart(sb, ref indent, controller.name, parameters);
                    BlankLine(sb);
                    AddMembers(sb, ref indent, accessModifier, parameters);
                    BlankLine(sb);
                    AddIsCompatible(sb, ref indent, parameters);
                    BlankLine(sb);
                    AddReset(sb, ref indent, controller.name);
                }
                CloseBlock(sb, ref indent);
            }
            if (hasNamespace)
            {
                CloseBlock(sb, ref indent);
            }

            return(sb.ToString());
        }
 static public void FastSetter(this UnityEngine.Animator o, string propertyName, UnityEngine.RuntimeAnimatorController value)
 {
     switch (propertyName)
     {
     case "runtimeAnimatorController":
         o.runtimeAnimatorController = value; return;
     }
     LBoot.LogUtil.Error("UnityEngine.Animator no Setter Found : " + propertyName);
 }
Example #14
0
 public static void CreateAnimator(GameObject root, UmaTPose umaTPose, RuntimeAnimatorController controller,bool applyRootMotion, bool animatePhysics,AnimatorCullingMode cullingMode)
 {
     umaTPose.DeSerialize();
     var animator = root.AddComponent<Animator>();
     animator.avatar = CreateAvatar(root, umaTPose);
     animator.runtimeAnimatorController = controller;
     animator.applyRootMotion = applyRootMotion;
     animator.animatePhysics = animatePhysics;
     animator.cullingMode = cullingMode;
 }
Example #15
0
 // Use this for initialization
 void Start()
 {
     audSource = GameObject.Find("ApplicationGlobal").GetComponent<AudioSource>();
     m_light = GameObject.Find("Directional light").GetComponent<Light>();
     spawnManager = GameObject.Find("SpawnManager").GetComponent<SpawnManager>();
     dragon = Resources.Load<RuntimeAnimatorController>("Animations/Dragon");
     dragonIce = Resources.Load<RuntimeAnimatorController>("Animations/DragonIce");
     dragon2 = Resources.Load<RuntimeAnimatorController>("Animations/Dragon2");
     dragon2Ice = Resources.Load<RuntimeAnimatorController>("Animations/Dragon2Ice");
 }
Example #16
0
 public FireProps(Vector2 direction, Vector2 position, RuntimeAnimatorController animController, float bulletSpeed, int damage, string weapon, WeaponEnum weapEnum)
 {
     this.direction = direction;
     this.position = position;
     this.animController = animController;
     this.bulletSpeed = bulletSpeed;
     this.damage = damage;
     this.weapon = weapon;
     this.weapEnum = weapEnum;
 }
 static public int get_animationClips(IntPtr l)
 {
     try {
         UnityEngine.RuntimeAnimatorController self = (UnityEngine.RuntimeAnimatorController)checkSelf(l);
         pushValue(l, self.animationClips);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #18
0
 public static Animator CreateAnimator(UMAData umaData, UmaTPose umaTPose, RuntimeAnimatorController controller, bool applyRootMotion, bool animatePhysics, AnimatorCullingMode cullingMode)
 {
     umaTPose.DeSerialize();
     var animator = umaData.umaRoot.AddComponent<Animator>();
     animator.avatar = CreateAvatar(umaData, umaTPose);
     animator.runtimeAnimatorController = controller;
     animator.applyRootMotion = applyRootMotion;
     animator.animatePhysics = animatePhysics;
     animator.cullingMode = cullingMode;
     return animator;
 }
Example #19
0
    // Use this for initialization
    void Start()
    {
        // Set at runtime, and typcast as runtime controller.
        _animatorController = Resources.Load(Resource.AnimatorController) as RuntimeAnimatorController;
        // Actually set it to the animatorController.
        _animator.runtimeAnimatorController = _animatorController;

        // Set default values for characters for universal across
        _controller.center = new Vector3(0f, 1f, 0f); // Middle of player
        _controller.height = 1.0f;
    }
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.RuntimeAnimatorController o;
         o = new UnityEngine.RuntimeAnimatorController();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
Example #21
0
	/// <summary>
	/// Initialize components.
	/// </summary>
	void Start () {
		// Rigidbody
		body.mass = 100f;
		body.constraints = RigidbodyConstraints.FreezeRotation;
		// Capsule Collider
		col.height = 1.5f;
		col.center = new Vector3(0f, 0.735f, 0f);
		col.radius = 0.35f;
		// Animator
		animator_controller = Resources.Load(Resource.AnimatorController) as RuntimeAnimatorController;
		animator.runtimeAnimatorController = animator_controller;
	}
	public void FillStateNames(RuntimeAnimatorController animator){
		List<string> names = new List<string> ();
		int layerCount =(animator as AnimatorController).layerCount;
		for (int layer = 0; layer < layerCount; layer++) {
			StateMachine stateMachine = (animator as AnimatorController).GetLayer(layer).stateMachine;
			int stateCount=stateMachine.stateCount;
			for (int state=0;state<stateCount;state++) {
				names.Add(stateMachine.GetState(state).uniqueName);
			}
		}
		stateNames = names.ToArray ();
	}
Example #23
0
        public IEnumerator Init()
        {
            this.InitGlobal();
            this.InitUI();
            this.InitWorld();

            Animations = (RuntimeAnimatorController)Resources.Load("Player/PlayerController", typeof(RuntimeAnimatorController));
            if (Animations==null) ui.error("ErrorCreatePlayer", "PlayerController");

            go = Util.GO.Create ( "Players", scene.transform, Util.GO.Layer.Players );

            yield break;
        }
Example #24
0
 static public int constructor(IntPtr l)
 {
     LuaDLL.lua_remove(l, 1);
     UnityEngine.RuntimeAnimatorController o;
     if (matchType(l, 1))
     {
         o = new UnityEngine.RuntimeAnimatorController();
         pushObject(l, o);
         return(1);
     }
     LuaDLL.luaL_error(l, "New object failed.");
     return(0);
 }
Example #25
0
// fields

// properties
    static void RuntimeAnimatorController_animationClips(JSVCall vc)
    {
        UnityEngine.RuntimeAnimatorController _this = (UnityEngine.RuntimeAnimatorController)vc.csObj;
        var result = _this.animationClips;
        var arrRet = result;

        for (int i = 0; arrRet != null && i < arrRet.Length; i++)
        {
            JSMgr.datax.setObject((int)JSApi.SetType.SaveAndTempTrace, arrRet[i]);
            JSApi.moveSaveID2Arr(i);
        }
        JSApi.setArrayS((int)JSApi.SetType.Rval, (arrRet != null ? arrRet.Length : 0), true);
    }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.RuntimeAnimatorController o;
         o=new UnityEngine.RuntimeAnimatorController();
         pushValue(l,o);
         return 1;
     }
     catch(Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return 0;
     }
 }
Example #27
0
 static public int constructor(IntPtr l)
 {
     try {
         UnityEngine.RuntimeAnimatorController o;
         o = new UnityEngine.RuntimeAnimatorController();
         pushValue(l, o);
         return(1);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #28
0
    public void fire(Vector2 direction, Vector2 position, RuntimeAnimatorController animController, float bulletSpeed, int damage, string weapon)
    {
        prefabBullets[indexUsedBullet].GetComponent<Bullet>().iniciate(
            direction,
            position,
            animController,
            bulletSpeed,
            damage,
            weapon
            );

        indexUsedBullet = (indexUsedBullet + 1) % maxBullets;
    }
 public static int constructor(IntPtr l)
 {
     try {
         UnityEngine.RuntimeAnimatorController o;
         o=new UnityEngine.RuntimeAnimatorController();
         pushValue(l,true);
         pushValue(l,o);
         return 2;
     }
     catch(Exception e) {
         return error(l,e);
     }
 }
Example #30
0
  public void AddRitualPoint(RuntimeAnimatorController controller)
  {
    IsRitualPoint = true;

    var renderer = AddSprite(null);
    var animator = renderer.gameObject.AddComponent<Animator>();
    animator.runtimeAnimatorController = controller;

    Action = () =>
    {
      IsActivated = true;
      GameStatus.ActivateRitualPoint();
      animator.Play("RitualActivating");

      if (GameStatus.RitualPointsRemaining == 0)
      {
        GameStatus.Root.SoundPlayer.Play(GameStatus.Root.SoundBank.Happy);
        GameStatus.Root.SoundPlayer.Play(GameStatus.Root.SoundBank.Win);
        GameStatus.Root.Player.enabled = false;
        GameStatus.LevelsCompleted++;

        var portalPlain = AddSprite(GameStatus.Root.SpriteBank.PortalPlain);
        var portalGlow = AddSprite(GameStatus.Root.SpriteBank.PortalGlow);

        var rotationZ = UnityEngine.Random.Range(0f, 360f);
        var rotationSpeed = 100f;

        var scale = Vector3.one;
        var scaleSpeed = 4f;

        portalGlow.color = new Color(portalGlow.color.r, portalGlow.color.g, portalGlow.color.b, 0f);
        portalGlow.DOFade(1f, 2f).OnUpdate(() =>
        {
          rotationZ += rotationSpeed * Time.deltaTime;
          scale += (Vector3.one * scaleSpeed) * Time.deltaTime;
          foreach (var r in new[] { portalPlain, portalGlow })
          {
            r.transform.rotation = Quaternion.Euler(0f, 0f, rotationZ);
            r.transform.localScale = scale;
          }
        }).OnComplete(() =>
        {
          GameStatus.Root.ExitLevel("MainGame");
        });
      }
    };

    name = "Ritual Point";
  }
Example #31
0
// fields

// properties
    static void AnimatorOverrideController_runtimeAnimatorController(JSVCall vc)
    {
        if (vc.bGet)
        {
            UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj;
            var result = _this.runtimeAnimatorController;
            JSMgr.datax.setObject((int)JSApi.SetType.Rval, result);
        }
        else
        {
            UnityEngine.RuntimeAnimatorController  arg0  = (UnityEngine.RuntimeAnimatorController)JSMgr.datax.getObject((int)JSApi.GetType.Arg);
            UnityEngine.AnimatorOverrideController _this = (UnityEngine.AnimatorOverrideController)vc.csObj;
            _this.runtimeAnimatorController = arg0;
        }
    }
Example #32
0
        public void Init(RuntimeAnimatorController controller)
        {
            gameObject.layer = (int)Util.GO.Layer.Players;
            gameObject.transform.localPosition = Config.PlayerCenter;
            gameObject.transform.localRotation = Quaternion.identity;
            gameObject.transform.localScale = Config.ScaleObject;

            animator = gameObject.GetComponent<Animator>();

            if (animator!=null && controller!=null) {
                animator.runtimeAnimatorController = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(controller);
                animator.speed = Config.AnimationSpeedWorldObjects;
                animator.cullingMode = AnimatorCullingMode.AlwaysAnimate;
                animator.applyRootMotion = false;
            }
        }
 static int LoadAnimatorController(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 2);
         LuaFramework.ResourceManager obj = (LuaFramework.ResourceManager)ToLua.CheckObject <LuaFramework.ResourceManager>(L, 1);
         string arg0 = ToLua.CheckString(L, 2);
         UnityEngine.RuntimeAnimatorController o = obj.LoadAnimatorController(arg0);
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
Example #34
0
    static int set_runtimeAnimatorController(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.AnimatorOverrideController obj  = (UnityEngine.AnimatorOverrideController)o;
            UnityEngine.RuntimeAnimatorController  arg0 = (UnityEngine.RuntimeAnimatorController)ToLua.CheckObject <UnityEngine.RuntimeAnimatorController>(L, 2);
            obj.runtimeAnimatorController = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index runtimeAnimatorController on a nil value"));
        }
    }
    static int _CreateRuntimeAnimatorController(IntPtr L)
    {
        int count = LuaDLL.lua_gettop(L);

        if (count == 0)
        {
            RuntimeAnimatorController obj = new RuntimeAnimatorController();
            LuaScriptMgr.Push(L, obj);
            return 1;
        }
        else
        {
            LuaDLL.luaL_error(L, "invalid arguments to method: RuntimeAnimatorController.New");
        }

        return 0;
    }
Example #36
0
    static int set_controller(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Spine.Unity.SkeletonDataAsset         obj  = (Spine.Unity.SkeletonDataAsset)o;
            UnityEngine.RuntimeAnimatorController arg0 = (UnityEngine.RuntimeAnimatorController)ToLua.CheckObject <UnityEngine.RuntimeAnimatorController>(L, 2);
            obj.controller = arg0;
            return(0);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index controller on a nil value"));
        }
    }
Example #37
0
    static int get_controller(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            Spine.Unity.SkeletonDataAsset         obj = (Spine.Unity.SkeletonDataAsset)o;
            UnityEngine.RuntimeAnimatorController ret = obj.controller;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index controller on a nil value"));
        }
    }
        /// <summary>
        /// Read the data into the specified value.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="reader">Reader.</param>
        public override void ReadInto(object value, ISaveGameReader reader)
        {
            UnityEngine.RuntimeAnimatorController runtimeAnimatorController = (UnityEngine.RuntimeAnimatorController)value;
            foreach (string property in reader.Properties)
            {
                switch (property)
                {
                case "name":
                    runtimeAnimatorController.name = reader.ReadProperty <System.String>();
                    break;

                case "hideFlags":
                    runtimeAnimatorController.hideFlags = reader.ReadProperty <UnityEngine.HideFlags>();
                    break;
                }
            }
        }
Example #39
0
    static int get_runtimeAnimatorController(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.AnimatorOverrideController obj = (UnityEngine.AnimatorOverrideController)o;
            UnityEngine.RuntimeAnimatorController  ret = obj.runtimeAnimatorController;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o, "attempt to index runtimeAnimatorController on a nil value"));
        }
    }
    static int get_animationClips(IntPtr L)
    {
        object o = null;

        try
        {
            o = ToLua.ToObject(L, 1);
            UnityEngine.RuntimeAnimatorController obj = (UnityEngine.RuntimeAnimatorController)o;
            UnityEngine.AnimationClip[]           ret = obj.animationClips;
            ToLua.Push(L, ret);
            return(1);
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e, o == null ? "attempt to index animationClips on a nil value" : e.Message));
        }
    }
Example #41
0
 internal static string GenerateFromController(
     Controller controller,
     string namespaceName,
     string className,
     AccessModifier accessModifier,
     bool isPartial
     )
 {
     Assert(controller != null, $"{nameof(controller)} == null");
     Assert(className != null, $"{nameof(className)} == null");
     return(Generate(
                controller,
                namespaceName,
                className,
                accessModifier,
                isPartial
                ));
 }
Example #42
0
        static Parameter[] GetParameters(Controller controller)
        {
            var gameObject = new GameObject()
            {
                hideFlags = HideFlags.HideAndDontSave
            };

            try {
                var animator = gameObject.AddComponent <Animator>();
                animator.runtimeAnimatorController = controller;
                return(animator.parameters);
            } finally {
                if (gameObject != null)
                {
                    GameObject.DestroyImmediate(gameObject);
                }
            }
        }
Example #43
0
 public static Animator CreateAnimator(UMAData umaData, UmaTPose umaTPose, RuntimeAnimatorController controller, bool applyRootMotion, bool animatePhysics, AnimatorCullingMode cullingMode)
 {
     var animator = umaData.umaRoot.AddComponent<Animator>();
     switch (umaData.umaRecipe.raceData.umaTarget)
     {
         case RaceData.UMATarget.Humanoid:
             umaTPose.DeSerialize();
             animator.avatar = CreateAvatar(umaData, umaTPose);
             break;
         case RaceData.UMATarget.Generic:
             animator.avatar = CreateGenericAvatar(umaData);
             break;
     }
     animator.runtimeAnimatorController = controller;
     animator.applyRootMotion = applyRootMotion;
     animator.animatePhysics = animatePhysics;
     animator.cullingMode = cullingMode;
     return animator;
 }
	// Update is called once per frame
	void Update () {
		if(player_1 == null){
			player_1 = GameObject.Find("Player1").GetComponent<Player1>();
		}
		
		if(player_2 == null){
			player_2 = GameObject.Find("Player2").GetComponent<Player2>();
		}
		
		if(anim1 == null){
			// Load player 1's character (default = Dennis)
			if(savedSelections.selected_p1 == "S. Racks"){
				anim1 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/SRacks", typeof(RuntimeAnimatorController)));
			}else if(savedSelections.selected_p1 == "SH1-V4"){
				anim1 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/SH1V4", typeof(RuntimeAnimatorController)));
			}else if(savedSelections.selected_p1 == "Colonel Topspin"){
				anim1 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/ColonelTopspin", typeof(RuntimeAnimatorController)));
			}else{
				anim1 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/Dennis", typeof(RuntimeAnimatorController)));
			}
		}else{
			// Set the animator controller
			player_1._animator.runtimeAnimatorController = anim1;
		}
	
		if(anim2 == null){
			// Load player 2's character (default = S. Racks)
			if(savedSelections.selected_p2 == "Dennis"){
				anim2 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/Dennis", typeof(RuntimeAnimatorController)));
			}else if(savedSelections.selected_p2 == "SH1-V4"){
				anim2 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/SH1V4", typeof(RuntimeAnimatorController)));
			}else if(savedSelections.selected_p2 == "Colonel Topspin"){
				anim2 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/ColonelTopspin", typeof(RuntimeAnimatorController)));
			}else{
				anim2 = (RuntimeAnimatorController)RuntimeAnimatorController.Instantiate(Resources.Load("Anims/SRacks", typeof(RuntimeAnimatorController)));
			}
		}else{
			// Set the animator controller
			player_2._animator.runtimeAnimatorController = anim2;
		}
	}
Example #45
0
    public IEnumerator RunDialog(RuntimeAnimatorController[] protagonist, DialogEntry[] dialogLine, System.Action<bool> callback)
    {
        dialogUI.SetActive (true);
        standardUI.SetActive (false);
        int currentLine = 0;

        Image leftSprite = leftPortrait.GetComponent<Image> ();
        Image rightSprite = rightPortrait.GetComponent<Image> ();
        Color leftColor = leftSprite.color;
        Color rightColor = rightSprite.color;

        // Initialisation
        leftPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter];
        rightPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter];

        // Tant qu'on n'a pas atteint la fin du dialogue, on défile
        while (currentLine < dialogLine.Length) {
            dialogText.text = dialogLine [currentLine].textLine;

            if (dialogLine [currentLine].portraitPosition == DialogEntry.PortraitPosition.left) {
                rightColor.a = 0.25f;
                rightSprite.color = rightColor;
                leftColor.a = 1;
                leftSprite.color = leftColor;
                leftPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter];
                leftPortrait.enabled = true;
                rightPortrait.enabled = false;
            } else if (dialogLine [currentLine].portraitPosition == DialogEntry.PortraitPosition.right) {
                rightColor.a = 1;
                rightSprite.color = rightColor;
                leftColor.a = 0.25f;
                leftSprite.color = leftColor;
                rightPortrait.runtimeAnimatorController = protagonist [dialogLine [currentLine].numCharacter];
                rightPortrait.enabled = true;
                leftPortrait.enabled = false;
            }

            // Si on appuie sur une touche, on affiche l'entrée suivante
            if (Input.GetMouseButtonDown (0))
                currentLine++;

            yield return null;
        }

        dialogUI.SetActive (false);
        standardUI.SetActive (true);
        callback (true);
    }
 public void setAnimationController(RuntimeAnimatorController rac)
 {
     rac.animationClips[0].wrapMode = WrapMode.Once;
     this.Animator.runtimeAnimatorController = rac;
 }
Example #47
0
        // General purpose generation.

        static string ClassName(Controller controller)
        {
            return(controller.name);
        }
Example #48
0
	public AnimationExportData (Transform transform, bool useQuaternion, float samplesPerSec)
	{
		t = transform;

		Animator ator = t.GetComponent<Animator>();

		a = ator.runtimeAnimatorController;

		samplingRate = 1.0f / samplesPerSec;

		defaultAnimation = a.animationClips[0];

		AnimationClipCurveData[] data = AnimationUtility.GetAllCurves (defaultAnimation, true);
		properties = new Hashtable();

		Debug.Log(data);

		/*

		foreach (AnimationClipCurveData d in data) {
			string un = d.propertyName;
			string jn = AnimationUtil.ExtractPropertyName (un);
			bool doExport = AnimationUtil.CheckForEulerHint (un);
			
			//Debug.Log ("Property: " + un + " as " + jn + " is exported " + doExport);
			
			AnimationProperty p = new AnimationProperty (jn);
			
			numSamples = 0;
			for (float i = 0; i <= defaultAnimation.length; i += samplingRate) {
				p.Samples.Add(d.curve.Evaluate(i));
				numSamples++;
			}
			
			if (doExport)
				properties.Add (jn, p);
		}
		
		for(int i = 0; i < numSamples; i++) {
			if(properties.ContainsKey("pz")) {
				float px = ( (AnimationProperty) properties["px"] ).Samples[i];	
				float py = ( (AnimationProperty) properties["py"] ).Samples[i];	
				float pz = ( (AnimationProperty) properties["pz"] ).Samples[i];	
				pz = -pz;
				( (AnimationProperty) properties["px"] ).SamplesEx.Add ( px.ToString (ExporterProps.LN) );
				( (AnimationProperty) properties["py"] ).SamplesEx.Add ( py.ToString (ExporterProps.LN) );
				( (AnimationProperty) properties["pz"] ).SamplesEx.Add ( pz.ToString (ExporterProps.LN) );
			}
			
			if(properties.ContainsKey("rx")) {
				Quaternion r = new Quaternion();
				r.x = ( (AnimationProperty) properties["rx"] ).Samples[i];	
				r.y = ( (AnimationProperty) properties["ry"] ).Samples[i];	
				r.z = -( (AnimationProperty) properties["rz"] ).Samples[i];
				r.w = ( (AnimationProperty) properties["rw"] ).Samples[i];
				
				r = Conversions.NormalizeQuaternion(r);

				if(!useQuaternion) { 
					Vector3 e = Conversions.SwitchRotation(r);
					( (AnimationProperty) properties["rx"] ).SamplesEx.Add ( e.x.ToString (ExporterProps.LN) );
					( (AnimationProperty) properties["ry"] ).SamplesEx.Add ( e.y.ToString (ExporterProps.LN) );
					( (AnimationProperty) properties["rz"] ).SamplesEx.Add ( e.z.ToString (ExporterProps.LN) );
				} else {	
					( (AnimationProperty) properties["rx"] ).SamplesEx.Add ( r.x.ToString (ExporterProps.LN) );
					( (AnimationProperty) properties["ry"] ).SamplesEx.Add ( r.y.ToString (ExporterProps.LN) );
					( (AnimationProperty) properties["rz"] ).SamplesEx.Add ( r.z.ToString (ExporterProps.LN) );
					( (AnimationProperty) properties["rw"] ).SamplesEx.Add ( r.w.ToString (ExporterProps.LN) );
				}
		*/
				
				/*
				Vector3 r = new Vector3();
				r.x = ( (AnimationProperty) properties["rx"] ).Samples[i];	
				r.y = ( (AnimationProperty) properties["ry"] ).Samples[i];	
				r.z = ( (AnimationProperty) properties["rz"] ).Samples[i];
								
				( (AnimationProperty) properties["rx"] ).SamplesEx.Add ( r.x.ToString (ExporterProps.LN) );
				( (AnimationProperty) properties["ry"] ).SamplesEx.Add ( r.y.ToString (ExporterProps.LN) );
				( (AnimationProperty) properties["rz"] ).SamplesEx.Add ( r.z.ToString (ExporterProps.LN) );
				*/
			// }
		}
 // upon recycling, clear previous references and fade gameObject to zero
 void OnDisable()
 {
     anim = null;
     weapon = null;
     animator.runtimeAnimatorController = null;
     spriteRenderer.sprite = null;
     CancelInvoke();
     MFX.Fade(spriteRenderer, 0f, 0f, 0f);
 }
 /// <summary>
 /// Write the specified value using the writer.
 /// </summary>
 /// <param name="value">Value.</param>
 /// <param name="writer">Writer.</param>
 public override void Write(object value, ISaveGameWriter writer)
 {
     UnityEngine.RuntimeAnimatorController runtimeAnimatorController = (UnityEngine.RuntimeAnimatorController)value;
     writer.WriteProperty("name", runtimeAnimatorController.name);
     writer.WriteProperty("hideFlags", runtimeAnimatorController.hideFlags);
 }
Example #51
0
 public void DestroyControllerInstance(RuntimeAnimatorController insController_)
 {
     UtilApi.Destroy(insController_);
 }
Example #52
0
 public RuntimeAnimatorController InstantiateController()
 {
     m_insController = UtilApi.Instantiate(m_controller.m_animatorController) as RuntimeAnimatorController;
     return m_insController;
 }
Example #53
0
 /// <summary>
 /// Initialize the swapping animation for the button
 /// </summary>
 private void initializeSwapAnimations()
 {
     m_SwapAnimator = Resources.Load("RunTimeAnimations/SwapAnimation/" + Enum.GetName(typeof(eAnimationSkin),
                         LevelManager.manager.AnimationSkin)) as RuntimeAnimatorController;
 }