Esempio n. 1
0
        private void DisableObject()
        {
            EventSystemManager.SetSelectionNull();

            foreach (Transform child in _buttonsContainer)
            {
                if (child == null)
                {
                    continue;
                }

                if (child.TryGetComponent <Button>(out Button button))
                {
                    button.onClick.RemoveListener(DisableObject);
                }
            }

            if (finishQustionEnum == FinishQustionEnum.Destroy)
            {
                GameObjectExtend.DestroyGameObject(gameObject);
            }
            else if (finishQustionEnum == FinishQustionEnum.Disactive)
            {
                gameObject.SetActive(false);
            }
        }
Esempio n. 2
0
    protected override void addTile(int x, int y, int id)
    {
        //SPECIAL CHEAP
        if (id == 6)
        {
            chunk.startingChunk      = true;
            chunk.checkPointLocation = new Vector2(x, y);
        }



        if (id > linker.prefabs.Count)
        {
            Debug.LogError("Il manque des prefab dans le linker." + " : je ne connais pas id " + id + ". Quesque tu as fais OLI!");
        }
        else if (id != 0)
        {
            GameObject prefab = linker.prefabs[id];
            if (prefab == null)
            {
                Debug.LogWarning("Erreur au block " + x + "," + y + " : je ne connais pas id " + id + ". Quesque ta faite Õli!!");
            }
            else
            {
                Vector3 position = new Vector3(x, y, 0);
                GameObjectExtend.createClone(prefab, prefab.name, tilesParent, position);
            }
        }
    }
Esempio n. 3
0
 static void Start()
 {
     if (!GameObject.FindObjectOfType <GameManager>())
     {
         GameObjectExtend.CreateGameObject("GameManager", null, true, typeof(GameManager));
     }
 }
Esempio n. 4
0
        public void FillContent(ref List <T> content)
        {
            if (content == null || scroll == null)
            {
                return;
            }

            for (int i = 1; i < multiplyNumberElements; i++)
            {
                content.AddRange(content);
            }

            var transforms = new List <Transform>();

            foreach (var info in content)
            {
                GameObjectExtend.CreateUIlement(prefab, out GameObject obj, CanvasTipology.Null);

                var element = obj.GetComponent <IElement <T, F> >();
                if (element != null)
                {
                    element.SetContent(info);
                }
                transforms.Add(obj.transform);
            }


            _contentList = content;

            scroll.SetNewItems(ref transforms);
        }
Esempio n. 5
0
        public void CreateNavbarElements(params NavbarInfoElement[] elements)
        {
            if (elements != null)
            {
                foreach (var element in elements)
                {
                    if (element != null)
                    {
                        NavbarElement navbarElement = null;

                        if (usePool)
                        {
                            PoolManager.Instantiate <NavbarElement>(out navbarElement, navbarElementPrefab, transform);
                        }
                        else
                        {
                            GameObjectExtend.CreateGameObject <NavbarElement>(navbarElementPrefab, out navbarElement, transform);
                        }

                        if (navbarElement != null)
                        {
                            navbarElement.UpdateElement(element);
                            navbarElements.Add(navbarElement);
                        }
                    }
                }
            }
        }
        public void CreateNewElements(object[] containers)
        {
            DebugVar[] fields = GetMembers(containers);

            if (fields == null || _debugScreenParent == null)
            {
                return;
            }

            foreach (var field in fields)
            {
                bool isExist = false;

                foreach (Transform child in _debugScreenParent)
                {
                    if (child.TryGetComponent <DebugScreenElement>(out var e))
                    {
                        if (e.NameField == field.name)
                        {
                            isExist = true;
                            break;
                        }
                    }
                }

                if (!isExist && GameObjectExtend.CreateGameObject <DebugScreenElement>(debugScreenElementPrefab, out var element, _debugScreenParent))
                {
                    element.SetField(field.member, field.name);
                }
            }
        }
Esempio n. 7
0
    static void Font(Text p_text)
    {
        GUILayout.Label("預設字體:" + UiCreatTool.fontPath);

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("使用預設字體"))
        {
            UiCreatTool.FixFont(p_text);
        }
        if (GUILayout.Button("將字體設為預設值"))
        {
            UiCreatTool.SetFont(p_text.font);
        }
        EditorGUILayout.EndHorizontal();

        EditorGUILayout.BeginHorizontal();
        if (GUILayout.Button("將字體套用到子物件"))
        {
            Text[] _texts = p_text.GetComponentsInChildren <Text>();
            SetFont(_texts, p_text.font);
        }
        if (GUILayout.Button("將字體套用到Scene"))
        {
            Text[] _texts = GameObjectExtend.GetComponentsInScene <Text>();
            SetFont(_texts, p_text.font);
        }
        EditorGUILayout.EndHorizontal();
    }
Esempio n. 8
0
 protected override void OnExecute()
 {
     if (prefab != null)
     {
         GameObjectExtend.CreateGameObject(prefab.value, out _);
     }
     EndAction();
 }
 protected override void OnExecute()
 {
     if (obj != null)
     {
         GameObjectExtend.DestroyGameObject(obj.value);
     }
     EndAction();
 }
Esempio n. 10
0
    void loadNextMap()
    {
        currentMapIndex++;
        currentMap = GameObjectExtend.createClone(maps[currentMapIndex]);
        GameObject startLocation = currentMap.FindChildRecursive("StartLocation");

        Layer.playerGo.transform.position = startLocation.transform.position;
    }
Esempio n. 11
0
        public static void SaveAll()
        {
            var list = GameObjectExtend.FindInterfaces <IStoragePlayerPrefs>();

            foreach (var mono in list)
            {
                Save(mono);
            }
        }
Esempio n. 12
0
    public ChunkLoader(GameObject parent)
    {
        this.parent = parent;
        this.chunk  = parent.AddComponent <Chunk>();
        this.chunk.gameObject.layer = LayerMask.NameToLayer("Chunk");
        tilesParent = GameObjectExtend.createGameObject("Tiles", parent.transform, Vector3.zero).transform;

        findOrCreateLinker();
    }
Esempio n. 13
0
    void Start()
    {
#if UNITY_EDITOR
        Vector2 _viewSize = GameObjectExtend.GetViewSize();
        size *= _viewSize.x / _viewSize.y;
#else
        size *= (float)Screen.width / (float)Screen.height;
#endif
    }
Esempio n. 14
0
 public static GameObject CreatePrefab(PowerStruct pow, Transform emitter, Vector2 direction, params Tags[] tags)
 {
     translateVector = pow.distanceForInstantiate * direction;
     auxVector       = emitter.position + translateVector;
     auxObject       = GameObjectExtend.InstantiatePool(pow.prefab, auxVector, Quaternion.identity);
     auxObject.AddTags(tags);
     auxObject.layer = emitter.gameObject.layer;
     return(auxObject);
 }
Esempio n. 15
0
        void nameRotation(GameObject prefabToRotate, string fileFolder, string nameSuffix, Vector3 vector3)
        {
            GameObject clone = GameObjectExtend.createClone(prefabToRotate);

            clone.transform.localRotation = Quaternion.Euler(vector3);
            clone.name += nameSuffix;

            PrefabUtility.CreatePrefab(fileFolder + "/" + clone.name + ".prefab", clone);
            Object.DestroyImmediate(clone);
        }
        protected override void Start()
        {
            base.Start();

            if (DebugManager.GetActiveDebug("debugScreen"))
            {
                GameObjectExtend.CreateUIlement(debugScreenPrefab, out _debugScreenParent, CanvasTipology.Debug);
                CreateDebugScreen();
                _isDebugScreen = true;
            }
        }
Esempio n. 17
0
    void removeBulb()
    {
        hasBulb = false;
        var lights = GetComponentsInChildren <Light>();

        foreach (var lightComponent in lights)
        {
            lightComponent.enabled = false;
        }
        GameObjectExtend.createClone(lightBulbPrefab, null, transform.position);
    }
Esempio n. 18
0
    public void RemoveAllImage()
    {
        TempImageRemover[] _tempImages = GameObjectExtend.GetComponentsInScene <TempImageRemover>();
        int f;
        int len = _tempImages.Length;

        for (f = 0; f < len; f++)
        {
            _tempImages[f].RemoveImage();
        }
        Debug.Log("Remove " + len + " TempImage");
    }
Esempio n. 19
0
    public override void Reset()
    {
        switch (transType)
        {
        case E_ObjCmdTransType.Local:
            gameObject.transform.localScale = lastScale;
            break;

        case E_ObjCmdTransType.Global:
            GameObjectExtend.SetLossyScale(gameObject.transform, lastScale);
            break;
        }
    }
    public override void OnEnter()
    {
        GameObject newParticule     = GameObjectExtend.createClone(Layer.gravityChangerParticule);
        GravityChangerParticule gcp = newParticule.GetComponent <GravityChangerParticule>();

        newParticule.transform.position = transform.position;

        newParticule.GetComponent <Rigidbody2D>().SetVelocity(Layer.initialVelocity);

        gcp.gravity = Layer.particuleGravity;
        SwitchState <IngredientGravitychangerReload>();

        DiableManager.instance.addDiable(gcp);
    }
Esempio n. 21
0
        void makeCloneFor(string name, Sprite sprite)
        {
            GameObject     tileCenter = GameObjectExtend.createClone(currentAutotile.basePrefab);
            SpriteRenderer sr         = tileCenter.GetComponentInChildren <SpriteRenderer>();

            if (sr != null)
            {
                sr.sprite = sprite;
            }
            string path = "Assets" + currentAutotile.outputAssetFolder + "/" + currentAutotile.name + "_" + name + ".prefab";

            PrefabUtility.CreatePrefab(path, tileCenter);
            tileCenter.Remove();
        }
Esempio n. 22
0
 public void DestroyNavbarElements()
 {
     if (navbarElements != null)
     {
         foreach (var element in navbarElements)
         {
             if (element != null)
             {
                 GameObjectExtend.DestroyGameObject(element.gameObject);
             }
         }
         navbarElements.Clear();
     }
 }
Esempio n. 23
0
        // Start is called before the first frame update
        void Start()
        {
            var a = GameObjectExtend.FindGameObjectWithMultiTags(true, "enemy");

            UnityEngine.Debug.Log(a);
            a = GameObjectExtend.FindGameObjectWithMultiTags(false, "enemy");
            UnityEngine.Debug.Log(a);
            a = GameObjectExtend.FindGameObjectWithMultiTags(true, "enemy", "player");
            UnityEngine.Debug.Log(a);
            UnityEngine.Debug.Log(a.GetTags().PrintElements());
            UnityEngine.Debug.Log(a.HasTags(true, "player"));
            UnityEngine.Debug.Log(a.HasTags(false, "player"));
            a.RemoveTags("player");
            UnityEngine.Debug.Log(a.HasTags(false, "player"));
        }
Esempio n. 24
0
        protected override void OnExecute()
        {
            var active     = enableState.value == EnableEnum.Enable ? true : false;
            var gameObject = container != null ? container.value.GameObject : null;

            if (gameObject != null)
            {
                gameObject.SetActive(active);
                if (!active && destroy.IsExist(out var value) && value)
                {
                    GameObjectExtend.DestroyGameObject(gameObject);
                }
            }

            EndAction();
        }
Esempio n. 25
0
    void setUpPlayers()
    {
        if (player1prefab == null)
        {
            Debug.LogError("Il n'y a pas de prefab pour le player 1 !!!");
        }
        else
        {
            player1 = GameObjectExtend.createClone(player1prefab);
        }

        if (player2prefab != null)
        {
            player2 = GameObjectExtend.createClone(player2prefab);
        }
    }
Esempio n. 26
0
    override protected bool Cmd(Vector3 p_arg)
    {
        switch (transType)
        {
        case E_ObjCmdTransType.Local:
            lastScale = gameObject.transform.localScale;
            break;

        case E_ObjCmdTransType.Global:
            lastScale = gameObject.transform.lossyScale;
            break;

        default:
            lastScale = Vector3.one;
            break;
        }

        if (relatively)
        {
            p_arg = new Vector3(lastScale.x * p_arg.x,
                                lastScale.y * p_arg.y,
                                lastScale.z * p_arg.z);
        }
        if (lastScale.Equals(p_arg))
        {
            return(false);
        }
        else
        {
            switch (transType)
            {
            case E_ObjCmdTransType.Local:
                gameObject.transform.localScale = p_arg;
                break;

            case E_ObjCmdTransType.Global:
                GameObjectExtend.SetLossyScale(gameObject.transform, p_arg);
                break;
            }
            return(true);
        }
    }
Esempio n. 27
0
        protected GameObject FindObj()
        {
            if (Application.isPlaying)
            {
                _init = true;
            }

            if (keys != null && typeControl != null && typeControl.value == StringTypeControl.Name && usePrefab != null && usePrefab.value && prefabName != null && prefabName.value != null)
            {
                if (!keys.value.IsAlmostSpecificCount())
                {
                    keys.value = new string[1];
                }
                keys.value[0] = prefabName.value.name;
            }

            if (typeControl != null && keys != null && includeInactiveRoot != null && isEqualCountTags != null)
            {
                if (useRoot != null && useRoot.value)
                {
                    if ((rootTransform == null || rootTransform.value == null) && typeControlRoot != null && keysRoot != null && isEqualCountTagsRoot != null)
                    {
                        if (useCanvas != null && useCanvas.value && canvasTiplogy != null)
                        {
                            rootTransform = CanvasManager.GetChild(canvasTiplogy.value);
                        }
                        else
                        {
                            rootTransform = GameObjectExtend.Find <Transform>(typeControlRoot.value, keysRoot.value, isEqualCountTagsRoot.value);
                        }
                    }

                    return(GameObjectExtend.FindInHierarchy(typeControl.value, keys.value, rootTransform.value, includeInactiveRoot.value, isEqualCountTags.value));
                }
                else
                {
                    return(GameObjectExtend.Find(typeControl.value, keys.value, isEqualCountTags.value));
                }
            }

            return(null);
        }
Esempio n. 28
0
    void loadLevel(GameObject level)
    {
        SwitchState <GameManagerInGame>();
        if (levelGO != null)
        {
            Object.Destroy(levelGO);
        }

        levelGO = GameObjectExtend.createClone(level);
        mapData = levelGO.GetComponent <MapData>();

        relocatePlayersToStart();
        centerCamera();

        if (background != null)
        {
            background.transform.position   = new Vector3(mapData.width / 2 - 0.5f, mapData.height / 2 - 0.5f, 3);
            background.transform.localScale = new Vector3(mapData.width, mapData.height, 1);
        }
    }
Esempio n. 29
0
    GameObject getMeOrCreate(string prefabName, string prefabPath)
    {
        GameObject foundGO = GameObject.Find(prefabName);

        if (foundGO == null)
        {
            GameObject prefab = Resources.Load <GameObject>(prefabPath);
            if (prefab == null)
            {
                Debug.LogWarning("Developpeur noob, il manque le prefab de " + prefabName);
            }
            else
            {
                return(GameObjectExtend.createClone(prefab));
            }
        }
        else
        {
            return(foundGO);
        }
        return(null);
    }
Esempio n. 30
0
        protected override void OnExecute()
        {
            if (widget.IsExist(out var prefab) && canvasTipology != null && typeSibilling != null)
            {
                Transform aux = CanvasManager.GetWidget(prefab.name, canvasTipology.value);

                if (aux == null)
                {
                    GameObjectExtend.CreateUIlement(prefab, out aux, canvasTipology.value);
                }

                if (aux != null)
                {
                    if (saveIstanceLocation != null)
                    {
                        saveIstanceLocation.value = aux.gameObject;
                    }


                    aux.gameObject.SetActive(!isDisabled.value);

                    int pos = positionChild != null ? positionChild.value : 0;
                    aux.SetSibilling(typeSibilling.value, pos);


                    if (mode != null && !string.IsNullOrWhiteSpace(mode.value))
                    {
                        var genericPage = aux.GetComponent <GenericPage>();
                        if (genericPage)
                        {
                            genericPage.Mode = mode.value;
                        }
                    }
                }
            }
            EndAction();
        }