GetComponent() public method

public GetComponent ( Type type ) : Component
type Type
return Component
Example #1
0
File: Game.cs Project: Jahoe/Blocks
    /// <summary>
    /// Called when the block swap fails due to specified reason.
    /// </summary>
    /// <param name="block">Second block. First block is pulled from memory</param>
    private void BlockSelectionFail(Component block)
    {
        block.GetComponent<Block>().Selected = false;
        _swap.GridBlocks[_blockMemoryInt].GetComponent<Block>().Selected = false;

        block.GetComponent<Block>().AudioFail();

        _blockMemoryInt = -1;
        BlockSelectedCount = 0;
    }
Example #2
0
        protected (Component component, MemberInfo memberInfo) ParseViewEntry(Component viewProvider,
                                                                              string entry)
        {
            var(typeName, memberName) = ParseEntry2TypeMember(entry);

            var component = viewProvider.GetComponent(typeName);

            if (component == null)
            {
                Her.Error($"Can't find component of type: {typeName} on {viewProvider}.");
                return(null, null);
            }

            var viewMemberInfos = component.GetType().GetMember(memberName);

            if (viewMemberInfos.Length <= 0)
            {
                Her.Error($"Can't find member of name: {memberName} on {component}.");
                return(null, null);
            }

            var memberInfo = viewMemberInfos[0];

            return(component, memberInfo);
        }
Example #3
0
 //Should only be created as part of our base framework
 public static AiRig ExtractRigInfo(Component c)
 {
     var rig = c.GetComponent<AiRig>();
     if (rig == null)
         c.GetComponentInParent<AiRig>();
     return rig;
 }
 public static void AddHealth(Component entity, int health)
 {
     HealthHandler handler = entity.GetComponent<HealthHandler>();
     if (handler) {
         handler.AddHealth(health);
     }
 }
    public SourceBindingProperty(Component target, string fieldName)
    {
        mTarget = target;
        mName   = fieldName;

        var strs = mName.Split(':');

        var strComps = strs[0].Split('.');

        object obj = target.GetComponent(strComps[strComps.Length - 1]);

        if (obj == null)
        {
            throw new Exception("bad root name");
        }

        for (var i = 1; i < strs.Length - 1; i++)
        {
            var type         = obj.GetType();
            var propertyInfo = type.GetProperty(strs[i]);
            obj = propertyInfo.GetGetMethod().Invoke(obj, new object[] {});
        }

        mNotifyPropertyChanged = obj as INotifyPropertyChanged;
        if (mNotifyPropertyChanged == null)
        {
            return;
        }
        mPropertyName = strs[strs.Length - 1];
    }
 static int QPYX_GetComponent_YXQP(IntPtr L_YXQP)
 {
     try
     {
         int QPYX_count_YXQP = LuaDLL.lua_gettop(L_YXQP);
         if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <string>(L_YXQP, 2))
         {
             UnityEngine.Component QPYX_obj_YXQP = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L_YXQP, 1);
             string QPYX_arg0_YXQP             = ToLua.ToString(L_YXQP, 2);
             UnityEngine.Component QPYX_o_YXQP = QPYX_obj_YXQP.GetComponent(QPYX_arg0_YXQP);
             ToLua.Push(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else if (QPYX_count_YXQP == 2 && TypeChecker.CheckTypes <System.Type>(L_YXQP, 2))
         {
             UnityEngine.Component QPYX_obj_YXQP  = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L_YXQP, 1);
             System.Type           QPYX_arg0_YXQP = (System.Type)ToLua.ToObject(L_YXQP, 2);
             UnityEngine.Component QPYX_o_YXQP    = QPYX_obj_YXQP.GetComponent(QPYX_arg0_YXQP);
             ToLua.Push(L_YXQP, QPYX_o_YXQP);
             return(1);
         }
         else
         {
             return(LuaDLL.luaL_throw(L_YXQP, "invalid arguments to method: UnityEngine.Component.GetComponent"));
         }
     }
     catch (Exception e_YXQP)                {
         return(LuaDLL.toluaL_exception(L_YXQP, e_YXQP));
     }
 }
Example #7
0
    static int GetComponent(IntPtr L)
    {
#if UNITY_EDITOR
        ToluaProfiler.AddCallRecord("UnityEngine.Component.Register");
#endif
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes <string>(L, 2))
            {
                UnityEngine.Component obj = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L, 1);
                string arg0             = ToLua.ToString(L, 2);
                UnityEngine.Component o = obj.GetComponent(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes <System.Type>(L, 2))
            {
                UnityEngine.Component obj  = (UnityEngine.Component)ToLua.CheckObject <UnityEngine.Component>(L, 1);
                System.Type           arg0 = (System.Type)ToLua.ToObject(L, 2);
                UnityEngine.Component o    = obj.GetComponent(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Component.GetComponent"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
 static public int GetComponent(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, "GetComponent__Type", argc, 2, typeof(System.Type)))
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 3, out a1);
             var ret = self.GetComponent(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (matchType(l, "GetComponent__String", argc, 2, typeof(string)))
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.String         a1;
             checkType(l, 3, out a1);
             var ret = self.GetComponent(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function to call");
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
 static public int GetComponent(IntPtr l)
 {
     try {
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(string)))
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             var ret = self.GetComponent(a1);
             pushValue(l, ret);
             return(1);
         }
         else if (matchType(l, argc, 2, typeof(System.Type)))
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             var ret = self.GetComponent(a1);
             pushValue(l, ret);
             return(1);
         }
         LuaDLL.luaL_error(l, "No matched override function to call");
         return(0);
     }
     catch (Exception e) {
         LuaDLL.luaL_error(l, e.ToString());
         return(0);
     }
 }
Example #10
0
    static public bool GetComponent <COMPONENT>(this UnityEngine.Component pTarget, COMPONENT pComponent)
        where COMPONENT : UnityEngine.Component
    {
        pComponent = pTarget.GetComponent <COMPONENT>();

        return(pComponent != null);
    }
 public UIShowHideController(GameObject go, Component panel)
 {
     this.panel = panel;
     this.animator = (go != null) ? go.GetComponent<Animator>() : null;
     if (animator == null && panel != null) animator = panel.GetComponent<Animator>();
     this.animCoroutine = null;
 }
Example #12
0
    static int GetComponent(IntPtr L)
    {
        try
        {
            int count = LuaDLL.lua_gettop(L);

            if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Component), typeof(string)))
            {
                UnityEngine.Component obj = (UnityEngine.Component)ToLua.ToObject(L, 1);
                string arg0             = ToLua.ToString(L, 2);
                UnityEngine.Component o = obj.GetComponent(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else if (count == 2 && TypeChecker.CheckTypes(L, 1, typeof(UnityEngine.Component), typeof(System.Type)))
            {
                UnityEngine.Component obj  = (UnityEngine.Component)ToLua.ToObject(L, 1);
                System.Type           arg0 = (System.Type)ToLua.ToObject(L, 2);
                UnityEngine.Component o    = obj.GetComponent(arg0);
                ToLua.Push(L, o);
                return(1);
            }
            else
            {
                return(LuaDLL.luaL_throw(L, "invalid arguments to method: UnityEngine.Component.GetComponent"));
            }
        }
        catch (Exception e)
        {
            return(LuaDLL.toluaL_exception(L, e));
        }
    }
Example #13
0
 public void AddLink(Component obj)
 {
     if (IsFull) return;
     if (links == null) {
         links = new Rigidbody[4];
     }
     links[linkCount++] = obj.GetComponent<Rigidbody>();
 }
Example #14
0
 public static bool DeductHealth(Component entity, int health)
 {
     HealthHandler handler = entity.GetComponent<HealthHandler>();
     if (handler) {
         return handler.DeductHealth(health);
     }
     return false;
 }
Example #15
0
 void IInteractable.Interact(Component sender)
 {
     var damager = sender.GetComponent<IWallDamage>();
     if (damager != null)
     {
         DamageWall(damager.GetWallDamage());
     }
 }
Example #16
0
 public static Cooltimer Set(Component component, float cooltime, Action onFinished)
 {
     var cooltimer = component.GetComponent<Cooltimer>();
     if (cooltimer == null) cooltimer = component.gameObject.AddComponent<Cooltimer>();
     cooltimer.cooltime = cooltime;
     cooltimer.onFinished = onFinished;
     return cooltimer;
 }
Example #17
0
 // -------------------
 static public int IsThereEventSystemInTheScene()
 {
     UnityEngine.Component sysGo = (UnityEngine.Component)(GameObject.FindObjectOfType(typeof(UnityEngine.EventSystems.EventSystem)));
     if (sysGo == null)
     {
         return(0);
     }
     return(sysGo.GetComponent(typeof(ControlFreak2.GamepadInputModule)) ? 1 : -1);
 }
Example #18
0
 public void menu2option_(Component menu)
 {
     //RectTransform RT = menu_option.GetComponent<RectTransform>();
     Animator A = menu.GetComponent<Animator>();
     A.SetBool("IsOpen", true);
     GetComponent<Animator>().SetBool("IsOpen", false);
     //GetComponent("Menu").GetComponent<CanvasGroup>().alpha = 0;
     //GetComponent("Menu").GetComponent<RectTransform>().position = new Vector3(0,370,0);
     //RT.position = new Vector3(0, 370, 0);
 }
        private static IEnumerator MovePlane(Component plane, GameObject target)
        {
            if (plane == null) throw new ArgumentNullException("plane");

            var rotation = plane.GetComponent<Orbiting>();
            Destroy(rotation);
            var move = plane.gameObject.AddComponent<MoveToTarget>();
            move.Target = target;
            yield return 0;
        }
Example #20
0
 void OnTriggerEnter(Component other)
 {
     if (other.name.Equals ("Player")) {
         Player player = other.GetComponent<Player>();
         if(player != null){
             print ("Geyser burn");
             player.currentHealth -= (int) (player.startingHealth * .10);
         }
     }
 }
Example #21
0
        private static bool DontValidateIfMeshRenderer(object obj)
        {
            UnityEngine.Component component = obj as UnityEngine.Component;
            if (component == null)
            {
                return(true);
            }

            return(component.GetComponent <MeshRenderer>() == null);
        }
Example #22
0
        // Get or Add component one time
        static public T GetOrAddComponent <T>(this UnityEngine.Component child) where T : UnityEngine.Component
        {
            T result = child.GetComponent <T>();

            if (result == null)
            {
                result = child.gameObject.AddComponent <T>();
            }
            return(result);
        }
		private static void ProcessDepthOfField(Component gameComponent, Component sceneComponent)
		{
			Type dofType = sceneComponent.GetType();
			FieldInfo fPlaneField = dofType.GetField("focusPlane", Utilities.DEFAULT_BINDING_FLAG);
			if (fPlaneField == null) return;

			float currentValue = (float)fPlaneField.GetValue(sceneComponent);
			float factor = Mathf.Pow(Mathf.Pow(currentValue, 4) / (sceneComponent.GetComponent<Camera>().farClipPlane / gameComponent.GetComponent<Camera>().farClipPlane), 1.0f / 4);
			fPlaneField.SetValue(sceneComponent, factor);
		}
Example #24
0
        ///<summary> Returns true if the component existsed and was removed </summary>
        public static bool RemoveComponentImmediate <T>(this Component co, bool allowDestroyingAssets = false) where T : Component
        {
            T component = co.GetComponent <T>();

            if (component != null)
            {
                Object.DestroyImmediate(component, allowDestroyingAssets);
                return(true);
            }
            return(false);
        }
Example #25
0
        public static T GetOrAddComponent <T>(this Component co) where T : Component
        {
            T component = co.GetComponent <T>();

            if (component == null)
            {
                component = co.gameObject.AddComponent <T>();
            }

            return(component);
        }
Example #26
0
        ///<summary> Returns true if the component existsed and was removed </summary>
        public static bool RemoveComponent <T>(this Component co) where T : Component
        {
            T component = co.GetComponent <T>();

            if (component != null)
            {
                Object.Destroy(component);
                return(true);
            }
            return(false);
        }
Example #27
0
        public static T GetSafeComponent<T>(this UnityEngine.Component obj, T target) where T : MonoBehaviour
        {
            T component = obj.GetComponent<T>();

            if (component == null)
            {
                Debug.LogError("Expected to find component of type " + typeof(T) + " but found none", obj);
            }

            return component;
        }
    // Update is called once per frame
    void Update()
    {
        //Finds the point on the ground that is being moused over
        Ray camPoint = Camera.mainCamera.ScreenPointToRay(Input.mousePosition);
        RaycastHit hitInfo;
        bool overGround = Physics.Raycast(camPoint, out hitInfo, Mathf.Infinity, GlobalConstants.GROUND_MASK);//Mask to hit only the ground
        Debug.DrawRay(camPoint.origin, camPoint.direction * 100, overGround ? Color.green : Color.red);

        //The mouse isn't over the map
        if(!overGround) return;

        //Computer what tile that point is in
        OverTile.x = (int)(hitInfo.point.x / GlobalConstants.TileSize);
        OverTile.y = (int)(hitInfo.point.z / GlobalConstants.TileSize);

        if(GuiManager.InBuildMode)
        {
            if(HoverObject != null) HoverObject.gameObject.active = false;
            HoverObject = GuiManager.GetSelectedComponent();
            HoverObject.gameObject.active = true;

            Vector2 structSize = ((Structure)HoverObject.GetComponent("Structure")).Size;

            HoverObject.transform.position = new Vector3(OverTile.x, 0f, OverTile.y) * GlobalConstants.TileSize
                + new Vector3(GlobalConstants.TileSize, 0, GlobalConstants.TileSize) / 2;
        }
        else
            if(HoverObject != null)
                HoverObject.transform.position = new Vector3(-100, -100, -100);

        Debug.Log(hitInfo.point);

        if(Input.GetMouseButtonDown(0) && !lastMouse && overGround && GuiManager.SelectedStructure != null)
        {
            //Don't overwrite a structure
            if(WorldManager.GetStructureAt((int)OverTile.x, (int)OverTile.y) == null)
            {
                //Make sure the placement is valid
                if(WorldManager.isValidPlacement(GuiManager.SelectedStructure, (int)OverTile.x, (int)OverTile.y))
                {
                    Component newStructure = (Component)Instantiate(GuiManager.SelectedStructure);
                    Vector2 structSize = ((Structure)newStructure.GetComponent("Structure")).Size;

                    newStructure.transform.position = new Vector3(OverTile.x, 0f, OverTile.y) * GlobalConstants.TileSize
                        + new Vector3(GlobalConstants.TileSize, 0, GlobalConstants.TileSize) / 2;

                    //TODO: Do this smoother. Create and destroy seems inefficient
                    WorldManager.AddStructure(newStructure, (int)OverTile.x, (int)OverTile.y);
                }
            }
        }

        lastMouse = Input.GetMouseButtonDown(0);
    }
Example #29
0
        /// <summary>Gets the component, including checking children if specified</summary>
        /// <typeparam name="TComponent">Component type</typeparam>
        /// <param name="this">The UnityEngine Component</param>
        /// <param name="includeChildren">Whether to check children if the component is not found on the Component</param>
        /// <returns>The component, if found; otherwise, null.</returns>
        public static TComponent GetComponent <TComponent>(this UnityEngine.Component @this, bool includeChildren)
            where TComponent : UnityEngine.Component
        {
            var component = @this.GetComponent <TComponent>();

            if (component == null)
            {
                component = @this.GetComponentInChildren <TComponent>();
            }

            return(component);
        }
Example #30
0
    public static UnityEngine.Component GetComponent(UnityEngine.Component com, string type, ref string msg)
    {
        Type T = GetType(type);

        if (T == null)
        {
            msg = "Not a Type";
            return(null);
        }
        var v = com.GetComponent(T);

        return(v);
    }
Example #31
0
 static public int GetComponent(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
         int argc = LuaDLL.lua_gettop(l);
         if (matchType(l, argc, 2, typeof(string)))
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.String         a1;
             checkType(l, 2, out a1);
             var ret = self.GetComponent(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         else if (matchType(l, argc, 2, typeof(System.Type)))
         {
             UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
             System.Type           a1;
             checkType(l, 2, out a1);
             var ret = self.GetComponent(a1);
             pushValue(l, true);
             pushValue(l, ret);
             return(2);
         }
         pushValue(l, false);
         LuaDLL.lua_pushstring(l, "No matched override function GetComponent to call");
         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
 }
Example #32
0
    public void AddComponent(Component component)
    {
        Rigidbody2D rb = component.GetComponent<Rigidbody2D>();
        FixedJoint2D newJoint = gameObject.AddComponent<FixedJoint2D>();
        //RelativeJoint2D newJoint = gameObject.AddComponent<RelativeJoint2D>();
        newJoint.connectedBody = rb;

        if (components == null)
            components = new List<Component>();

        components.Add(component);
        component.Ship = this;
        transform.position = GetCenter();
        //print("woop " + component.GetInstanceID() + " #:" + components.Count);
    }
 static public int GetComponent__String(IntPtr l)
 {
     try {
         UnityEngine.Component self = (UnityEngine.Component)checkSelf(l);
         System.String         a1;
         checkType(l, 2, out a1);
         var ret = self.GetComponent(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
    public GLexMaterial(Material material, Component meshRenderer)
    {
        mMaterial = material;
        mMaterialSettings = meshRenderer.GetComponent<GLexMaterialSettings>();

        mUniqueName = mMaterial.name;
        while (UniqueNameExists( mUniqueName )) {
            mUniqueName = mMaterial.name + (mUniqueId++).ToString();
        }

        mMaterials.Add(this);

        AddTextures();
        AddShader();
    }
Example #35
0
        public static IList <T> GetInterfaceComponents <T>(this Component component, bool firstOnly = false) where T : class
        {
            var types = _interfaceToComponentMapping[typeof(T)];

            if (null == types || types.Count <= 0)
            {
                Debug.LogError("No descendants found for type " + typeof(T));
                return(null);
            }

            var resList = new List <T>();

            foreach (var curType in types)
            {
                Component[] components = firstOnly ?
                                         new [] { component.GetComponent(curType) }
                        : component.GetComponents(curType);

                if (null == components || components.Length <= 0)
                {
                    continue;
                }

                var tList = new List <T>();

                foreach (var curComp in components)
                {
                    if (curComp == null)
                    {
                        continue;
                    }

                    var curCompAsT = curComp as T;

                    if (null == curCompAsT)
                    {
                        Debug.LogError("Unable to cast '" + curComp.GetType() + "' to '" + typeof(T) + "'");
                        continue;
                    }

                    tList.Add(curCompAsT);
                }

                resList.AddRange(tList);
            }

            return(resList);
        }
Example #36
0
    /// <summary>
    /// 自动 脚本 控制
    /// Gets or add a component. Usage example:
    /// BoxCollider boxCollider = transform.GetOrAddComponent<BoxCollider>();
    /// </summary>
    public static T GetOrAddComponent <T>(this Component child) where T : Component
    {
        T result = child.GetComponent <T>();

        if (result == null)
        {
            try
            {
                result = child.gameObject.AddComponent <T>();
            }
            catch (Exception exception)
            {
                Debug.LogWarning("GetOrAddComponent=" + exception);
            }
        }
        return(result);
    }
Example #37
0
 public static int GetComponent2_wrap(long L)
 {
     try
     {
         long nThisPtr             = FCLibHelper.fc_get_inport_obj_ptr(L);
         UnityEngine.Component obj = get_obj(nThisPtr);
         string arg0 = FCLibHelper.fc_get_string_a(L, 0);
         UnityEngine.Component ret = obj.GetComponent(arg0);
         long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
         long v       = FCGetObj.PushObj(ret);
         FCLibHelper.fc_set_value_wrap_objptr(ret_ptr, v);
     }
     catch (Exception e)
     {
         Debug.LogException(e);
     }
     return(0);
 }
Example #38
0
   public void UpdateOrderGivenComponent(Component component) {
     if (Application.isPlaying) {
       return;
     }
 
     Camera camera = component.GetComponent<Camera>();
     if (camera == null) {
       camera = component.gameObject.AddComponent<Camera>();
     }
 
     SerializedObject obj = new SerializedObject(camera);
     SerializedProperty targetEyeProp = obj.FindProperty(TARGET_EYE_PROPERTY_NAME);
     OrderType newOrder = (OrderType)targetEyeProp.intValue;
     if (_orderType != newOrder) {
       _orderType = newOrder;
       EditorUtility.SetDirty(component);
     }
   }
        // NOTE (darren): we want to validate and check MeshFilters, but
        // TextMeshPro dynamically adds a mesh. As a requirement to validation,
        // MeshFilter must not have a TextMeshPro component as well
        private static bool DontValidateIfTextMeshPro(object obj)
        {
            UnityEngine.Component component = obj as UnityEngine.Component;
            if (component == null)
            {
                return(true);
            }

            Type textMeshProType = kTextMeshProType ?? kTextMeshProFirstPassType;

            if (textMeshProType == null)
            {
                return(true);
            }

            UnityEngine.Component textMeshProComponent = component.GetComponent(textMeshProType);
            // valid (true) when textMeshProComponent does not exist
            return(textMeshProComponent == null);
        }
Example #40
0
        public static T[] GetComponentsInChildrenExcludeSelf <T>(this Component component)
        {
            var childrenAndSelf = component.GetComponentsInChildren <T>();

            if (childrenAndSelf.Length == 0)
            {
                return(childrenAndSelf);
            }
            var hasT = component.GetComponent <T>();

            if (hasT == null)
            {
                return(childrenAndSelf);
            }

            var list = childrenAndSelf.ToList();

            list.RemoveAt(0);
            return(list.ToArray());
        }
Example #41
0
        public WeenusUI(Component unityComponent)
        {
            var buttons = new List<WeenusFieldButton>();
            var views = new List<WeenusFieldView>();
            var inputs = new List<WeenusInputField>();

            RectTransform rect = unityComponent.GetComponent<RectTransform>();

            GameObjectUtilities.GetAllComponentsInChildTree<WeenusFieldButton>(rect, buttons);
            GameObjectUtilities.GetAllComponentsInChildTree<WeenusFieldView>(rect, views);
            GameObjectUtilities.GetAllComponentsInChildTree<WeenusInputField>(rect, inputs);

            foreach (var b in buttons)
                Button.Add(b.gameObject.name, b);

            foreach (var b in views)
                FieldView.Add(b.gameObject.name, b);

            foreach (var b in inputs)
                FieldInput.Add(b.gameObject.name, b);
        }
Example #42
0
    private static void AddToCanvas(Component gobject)
    {
        var canvases = FindObjectsOfType<Canvas>();

        // Get the first screen overlay canvas we can find,
        // If one is not found get the first canvas of any type,
        // If no canvas is found, create a new one
        var canvas = canvases.FirstOrDefault(c => c.renderMode == RenderMode.ScreenSpaceOverlay) ??
                     canvases.FirstOrDefault() ?? new GameObject("Canvas").AddComponent<Canvas>();

        if (canvas)
        {
            var rect = gobject.GetComponent<RectTransform>();

            rect.SetParent(canvas.transform);
            rect.localScale = Vector3.one;
            rect.anchorMin = Vector2.zero;
            rect.anchorMax = Vector2.one;
            rect.pivot = Vector2.one * .5f;
            rect.sizeDelta = Vector2.zero;
            rect.anchoredPosition = Vector3.zero;
        }
    }
    /// <summary>
    /// Adds a structure at coordinates x, y
    /// </summary>
    /// <param name='structure'>
    /// The structure to add
    /// </param>
    /// <param name='x'>
    /// X coordinate
    /// </param>
    /// <param name='y'>
    /// Y coordinate
    /// </param>
    public static void AddStructure(Component structure, int x, int y)
    {
        Structure structCast = (Structure)(structure.GetComponent("Structure"));

        //Sanity Check
        if(structCast.needsAir && Tiles[x, y].state == TileStatus.State.Unpressurized) return;

        Tiles[x, y].structure = structure;
        Tiles[x, y].groundType = TileStatus.GroundType.Blocked;

        //marked tileStatus as sealed
        if(structCast.sealedBuilding)
        {
            for(int i = x - structCast.DomeRadius; i <= x + structCast.DomeRadius; i++)
                for(int j = y - structCast.DomeRadius; j <= y + structCast.DomeRadius; j++)
                {
                    if(Vector2.Distance(new Vector2(x, y), new Vector2(i, j)) <= structCast.DomeRadius)
                    {
                        Tiles[i,j].state = TileStatus.State.Pressurized;
                    }
                }
        }
    }
Example #44
0
    public void UpdateOrderGivenComponent(Component component) {
      if (Application.isPlaying) {
        return;
      }

      //Allow the user to specify themselves if VR is disabled
      if (!VRSettings.enabled || !PlayerSettings.virtualRealitySupported) {
        return;
      }

      Camera camera = component.GetComponent<Camera>();
      if (camera == null) {
        camera = component.gameObject.AddComponent<Camera>();
      }

      SerializedObject obj = new SerializedObject(camera);
      SerializedProperty targetEyeProp = obj.FindProperty(TARGET_EYE_PROPERTY_NAME);
      OrderType newOrder = (OrderType)targetEyeProp.intValue;
      if (_orderType != newOrder) {
        _orderType = newOrder;
        EditorUtility.SetDirty(component);
      }
    }
Example #45
0
    public static int GetComponent1_wrap(long L)
    {
        try
        {
            long nThisPtr             = FCLibHelper.fc_get_inport_obj_ptr(L);
            UnityEngine.Component obj = get_obj(nThisPtr);
            string arg0    = FCLibHelper.fc_get_string_a(L, 0);
            long   nRetPtr = 0;
            switch (arg0)
            {
            case "SkinnedMeshRenderer":
            {
                SkinnedMeshRenderer ret_obj = obj.GetComponent <SkinnedMeshRenderer>();
                nRetPtr = FCGetObj.PushObj <SkinnedMeshRenderer>(ret_obj);
            }
            break;

            case "Renderer":
            {
                Renderer ret_obj = obj.GetComponent <Renderer>();
                nRetPtr = FCGetObj.PushObj <Renderer>(ret_obj);
            }
            break;

            case "MeshRenderer":
            {
                MeshRenderer ret_obj = obj.GetComponent <MeshRenderer>();
                nRetPtr = FCGetObj.PushObj <MeshRenderer>(ret_obj);
            }
            break;

            case "Animation":
            {
                Animation ret_obj = obj.GetComponent <Animation>();
                nRetPtr = FCGetObj.PushObj <Animation>(ret_obj);
            }
            break;

            case "Collider":
            {
                Collider ret_obj = obj.GetComponent <Collider>();
                nRetPtr = FCGetObj.PushObj <Collider>(ret_obj);
            }
            break;

            case "BoxCollider":
            {
                BoxCollider ret_obj = obj.GetComponent <BoxCollider>();
                nRetPtr = FCGetObj.PushObj <BoxCollider>(ret_obj);
            }
            break;

            case "BoxCollider2D":
            {
                BoxCollider2D ret_obj = obj.GetComponent <BoxCollider2D>();
                nRetPtr = FCGetObj.PushObj <BoxCollider2D>(ret_obj);
            }
            break;

            case "MeshCollider":
            {
                MeshCollider ret_obj = obj.GetComponent <MeshCollider>();
                nRetPtr = FCGetObj.PushObj <MeshCollider>(ret_obj);
            }
            break;

            case "SphereCollider":
            {
                SphereCollider ret_obj = obj.GetComponent <SphereCollider>();
                nRetPtr = FCGetObj.PushObj <SphereCollider>(ret_obj);
            }
            break;

            case "Rigidbody":
            {
                Rigidbody ret_obj = obj.GetComponent <Rigidbody>();
                nRetPtr = FCGetObj.PushObj <Rigidbody>(ret_obj);
            }
            break;

            case "Camera":
            {
                Camera ret_obj = obj.GetComponent <Camera>();
                nRetPtr = FCGetObj.PushObj <Camera>(ret_obj);
            }
            break;

            case "AudioSource":
            {
                AudioSource ret_obj = obj.GetComponent <AudioSource>();
                nRetPtr = FCGetObj.PushObj <AudioSource>(ret_obj);
            }
            break;

            case "Transform":
            {
                Transform ret_obj = obj.GetComponent <Transform>();
                nRetPtr = FCGetObj.PushObj <Transform>(ret_obj);
            }
            break;

            case "Component":
            {
                Component ret_obj = obj.GetComponent <Component>();
                nRetPtr = FCGetObj.PushObj <Component>(ret_obj);
            }
            break;

            case "ParticleSystem":
            {
                ParticleSystem ret_obj = obj.GetComponent <ParticleSystem>();
                nRetPtr = FCGetObj.PushObj <ParticleSystem>(ret_obj);
            }
            break;

            case "Light":
            {
                Light ret_obj = obj.GetComponent <Light>();
                nRetPtr = FCGetObj.PushObj <Light>(ret_obj);
            }
            break;

            case "Button":
            {
                Button ret_obj = obj.GetComponent <Button>();
                nRetPtr = FCGetObj.PushObj <Button>(ret_obj);
            }
            break;

            case "Text":
            {
                Text ret_obj = obj.GetComponent <Text>();
                nRetPtr = FCGetObj.PushObj <Text>(ret_obj);
            }
            break;

            default:
                break;
            }
            long ret_ptr = FCLibHelper.fc_get_return_ptr(L);
            FCLibHelper.fc_set_value_wrap_objptr(ret_ptr, nRetPtr);
        }
        catch (Exception e)
        {
            Debug.LogException(e);
        }
        return(0);
    }
Example #46
0
 public static void SetTint(this Component component, Color color)
 {
     component.GetComponent <Renderer>().material.SetColor("_TintColor", color);
 }
Example #47
0
 public static PhotonView Get(Component component)
 {
     return component.GetComponent<PhotonView>();
 }
Example #48
0
	//-------------------------------------------------------------------------
	void EnsureOTTilesSpriteHasUpdateComponent(Component otTilesSprite) {
		AlphaMeshColliderUpdateOTTilesSpriteColliders updateComponent = otTilesSprite.GetComponent<AlphaMeshColliderUpdateOTTilesSpriteColliders>();
		if (updateComponent == null) {
			updateComponent = otTilesSprite.gameObject.AddComponent<AlphaMeshColliderUpdateOTTilesSpriteColliders>();
			updateComponent.SetOTTilesSprite(otTilesSprite);
		}
	}
Example #49
0
	//-------------------------------------------------------------------------
	void EnsureSmoothMovesBoneAnimHasRestoreComponent(Component smoothMovesBoneAnimation) {
		AlphaMeshColliderSmoothMovesRestore restoreComponent = smoothMovesBoneAnimation.GetComponent<AlphaMeshColliderSmoothMovesRestore>();
		if (restoreComponent == null) {
			smoothMovesBoneAnimation.gameObject.AddComponent<AlphaMeshColliderSmoothMovesRestore>();
		}
	}
Example #50
0
 public static Color GetTint(this Component component)
 {
     return(component.GetComponent <Renderer>().material.GetColor("_TintColor"));
 }
Example #51
0
 public static float GetMaxHealth(Component entity)
 {
     return 	entity.GetComponent<HealthHandler>().maxHealth;
 }
Example #52
0
        public static void LerpColor(this Component component, Color target, float amount)
        {
            var current = component.GetComponent <Renderer>().material.color;

            component.GetComponent <Renderer>().material.color = Color.Lerp(current, target, amount);
        }
Example #53
0
 public UIButton(Component but, Color mouseOver, Color selected, Color selectedOver)
 {
     button = but;
     butImage = but.GetComponent<Image>();
     origColor = butImage.color;
     mouseOvercolor = mouseOver;
     selectedColor = selected;
     selectedOverColor = selectedOver;
 }
Example #54
0
    public void OnEnableComponent(Component tarCom, bool bChangedEnable)
    {
        if (tarCom is NcParticleSystem)
        {
            if (tarCom.GetComponent<ParticleEmitter>() != null && NgSerialized.IsMeshParticleEmitter(tarCom.GetComponent<ParticleEmitter>()))
            {
                NcParticleSystem ncParticleScale = (tarCom as NcParticleSystem);
                float			fSetMinValue;
                float			fSetMaxValue;
                NgSerialized.GetMeshNormalVelocity(tarCom.GetComponent<ParticleEmitter>(), out fSetMinValue, out fSetMaxValue);

                if (bChangedEnable == true)
                {
                    ncParticleScale.m_fLegacyMinMeshNormalVelocity = fSetMinValue;
                    ncParticleScale.m_fLegacyMaxMeshNormalVelocity = fSetMaxValue;
                } else {
                    if (fSetMinValue != ncParticleScale.m_fLegacyMinMeshNormalVelocity || fSetMaxValue != ncParticleScale.m_fLegacyMaxMeshNormalVelocity)
                        NgSerialized.SetMeshNormalVelocity(tarCom.GetComponent<ParticleEmitter>(), ncParticleScale.m_fLegacyMinMeshNormalVelocity, ncParticleScale.m_fLegacyMaxMeshNormalVelocity);
                }
            }
        }
    }
Example #55
0
 public CGShapeResourceGUI(Component resource) : base(resource) 
 {
     mCurrentShape=resource.GetComponent<CurvyShape2D>();
     mMenuNames = CurvyShape.GetShapesMenuNames((mCurrentShape) ? mCurrentShape.GetType() : null, out mSelection,true).ToArray();
     mFreeform = (mCurrentShape == null);
 }
 public static Component GetComponent0T(this UnityEngine.Component self, System.Type T)
 {
     return(self.GetComponent(T));
 }
Example #57
0
  void OnTriggerEnter(Component component) {
    if (component.CompareTag("CheckPoint")) {
      LastCheckPoint = component.gameObject;
      component.gameObject.SetActive(false);
    }

    if (component.CompareTag("ActionPoint")) {
      component.gameObject.SetActive(false);
    }

    if (component.CompareTag("BadTouch") || (component.CompareTag("Enemy") && !Attacking)) {
      Kill();
    }

    if (component.CompareTag("Fallable")) {
      GetComponent<Collider>().isTrigger = false;
      component.GetComponent<Fallable>().Fall();
    }

    if (component.CompareTag("Breakable")) {
      component.GetComponent<Breakable>().Break();
    }
  }
Example #58
0
            /**
             * empty slot constructor
             */
            public UIItem(Component itemElem)
            {
                Text TG = null, TK = null, TT = null, TN = null;
                foreach (Text t in itemElem.GetComponentsInChildren<Text>())
                {
                    if (t.name.Equals("Text_G"))
                        TG = t;
                    else if (t.name.Equals("Text_K"))
                        TK = t;
                    else if (t.name.Equals("Text_T"))
                        TT = t;
                    else if (t.name.Equals("Text_N"))
                        TN = t;
                }

                _itemElem = itemElem;
                _itemElemBorderImage = itemElem.GetComponent<Image>();
                _origColor = _itemElemBorderImage.color;
                _but = itemElem.GetComponent<Button>();
                _value = new UICurrency(TG, TK, TT, TN);
            }
Example #59
0
 public static void SetEmissionColor(this Component component, Color color)
 {
     component.GetComponent <Renderer>().material.SetColor("_EmissionColor", color);
 }
Example #60
0
File: Game.cs Project: Jahoe/Blocks
    /// <summary>
    /// First and second block are compatable and can be killed off. Use this
    /// to kill the block and the one stored in memory. It also provides
    /// animation to the move counter.
    /// </summary>
    /// <param name="block">Second block. First block is pulled from memory</param>
    private void BlockSelectionPass(Component block)
    {
        block.GetComponent<Block>().Killed = true;
        _swap.GridBlocks[_blockMemoryInt].GetComponent<Block>().Killed = true;
        _blockMemoryInt = -1;
        block.GetComponent<Block>().AudioPass();
        _movesCountInt--;
        _movesLeftTextColourGreen = 0.75f;
        _fontSizeTemp = _movesLeftFontSize;
        _movesLeftFontSize = _movesLeftFontSize * 2;

        _blockMemoryInt = -1;
        BlockSelectedCount = 0;
    }