コード例 #1
0
    void onWebContextReadyListener(object obj, Callback cb)
    {
        Debug2.Log("im here from callback");
        string pageName = (string)obj;

        initData = "";
        if (pageName.StartsWith("mru"))
        {
            webType  = WebType.MAIL_RU;
            initData = mailRuKey;
        }
        else if (pageName.StartsWith("vk"))
        {
            webType  = WebType.VK;
            initData = vkKey;
        }
        else if (pageName.StartsWith("fb"))
        {
            webType = WebType.FB;
        }
        else if (pageName.StartsWith("online"))
        {
            webType = WebType.ONLINE;
        }
        else
        {
            Debug2.LogError("unknown page");
        }
        ready          = true;
        activeStrategy = supportedWeb[webType];
        activeStrategy.onStart(initData);
    }
コード例 #2
0
ファイル: Utils.cs プロジェクト: kingBook/as3_framework
    private static void createCharPointsGameObjectElement(GameObject gameObject, XmlElement parentElement, XmlDocument xml)
    {
        CharPoints[] charPointList = gameObject.GetComponents <CharPoints>();
        Debug2.Log(charPointList, charPointList.Length);
        if (charPointList.Length <= 0)
        {
            return;
        }

        XmlElement gameObjElement = xml.CreateElement("GameObject");

        gameObjElement.SetAttribute("name", gameObject.name);
        //gameObjElement.SetAttribute("tag",gameObject.tag);
        gameObjElement.SetAttribute("activeSelf", gameObject.activeSelf.ToString());
        //gameObjElement.SetAttribute("instanceID",gameObject.GetInstanceID().ToString());
        //解析组件
        for (int i = 0; i < charPointList.Length; i++)
        {
            parseCharPoints(charPointList[i], gameObjElement, xml);
            parentElement.AppendChild(gameObjElement);
        }
        //解析子对象
        Transform transform  = gameObject.GetComponent <Transform>();
        int       childCount = transform.childCount;

        for (int i = 0; i < childCount; i++)
        {
            GameObject subGameObj = transform.GetChild(i).gameObject;
            createCharPointsGameObjectElement(subGameObj, parentElement, xml);
        }
    }
コード例 #3
0
        /// <summary>
        /// objeyi yüklemeye yarar
        /// </summary>
        /// <typeparam name="T">Objenin türünü giriniz</typeparam>
        /// <param name="path">objenin Load edileceği yer örn: meshler</param>
        /// <param name="name">örn: /objeler.json ve .json  zorunlu</param>
        public async static UniTask <T[]> LoadArrayAsync <T>(string path, string name)
        {
            CheckPath(path);

            DirectoryInfo directoryInfo = new DirectoryInfo(SavesFolder + path);

            int count = directoryInfo.GetFiles().Length;

            T[] objectToLoad = new T[count];
            var tasks        = new List <UniTask>();

            for (int i = 0; i < count; i++)
            {
                tasks.Add(UniTask.Create(async() =>
                {
                    await UniTask.Yield();
                    string konum = Path.Combine(SavesFolder + path + i.ToString() + name);
                    if (File.Exists(konum))
                    {
                        string loadText = File.ReadAllText(konum);
                        objectToLoad[i] = JsonUtility.FromJson <T>(loadText);
                        Debug2.Log(loadText);
                    }
                }));
            }

            await UniTask.WhenAll(tasks);

            return(objectToLoad);
        }
コード例 #4
0
        public static void Register(ITickable task, UpdateType updateType = UpdateType.normal)
        {
            // be assure instance exist
            Checkinstance();
            var ableTask = Tasks.Find(x => x.InstanceId() == task.InstanceId() && x.InstanceId() != 0);

            if (ableTask != null)
            {
                switch (ableTask)
                {
                case MoveTask move:
                    move.Join(((MoveTask)task).CurrentData); break;

                case DirectionTask drecTask:
                    drecTask.Join(((DirectionTask)task).CurrentData); break;

                case UpdateTask updateTask:
                    Debug2.Log("update task exist it will add in queue");
                    updateTask.Join(((UpdateTask)task).currentData); break;
                }
            }
            else
            {
                if (updateType == UpdateType.normal)
                {
                    Tasks.Add(task);
                }
                else if (updateType == UpdateType.fixedTime)
                {
                    FixedTasks.Add(task);
                }
            }
        }
コード例 #5
0
        public static void EraseCircale(RaycastHit hit, int radius)
        {
            var anilMaterial = hit.collider.GetComponent <AnilMaterial>();

            if (!anilMaterial)
            {
                return;
            }

            renderer  = anilMaterial.renderer;
            texture2D = anilMaterial.texture2D;

            if (!texture2D.isReadable)
            {
                Debug2.Log("texture is not readable");
                return;
            }

            pCoord    = hit.textureCoord;
            pCoord.x *= texture2D.width;
            pCoord.y *= texture2D.height;

            int x = Mathf.RoundToInt(pCoord.x * renderer.material.mainTextureScale.x);
            int y = Mathf.RoundToInt(pCoord.y * renderer.material.mainTextureScale.y);

            anilMaterial.Erase(x, y, radius);
        }
コード例 #6
0
        public static void Test(string aName, Action a, string bName, Action b, long iteration)
        {
            Stopwatch stopwatch = new Stopwatch();

            Debug2.Log(aName);

            stopwatch.Start();

            for (long i = 0; i < iteration; i++)
            {
                a.Invoke();
            }

            stopwatch.Stop();
            Debug2.Log($" {stopwatch.ElapsedMilliseconds: 0.000}");

            stopwatch.Reset();
            Debug2.Log(bName);

            for (long i = 0; i < iteration; i++)
            {
                b.Invoke();
            }

            stopwatch.Stop();
            Debug2.Log($" {stopwatch.ElapsedMilliseconds: 0.000}");
        }
コード例 #7
0
    private static void OnPlayerModeStateChanged(PlayModeStateChange playModeState)
    {
        Debug.LogFormat("state:{0} will:{1} isPlaying:{2}", playModeState, EditorApplication.isPlayingOrWillChangePlaymode, EditorApplication.isPlaying);
        switch (playModeState)
        {
        case PlayModeStateChange.EnteredEditMode:
            break;

        case PlayModeStateChange.ExitingEditMode:
            Scene editorActiveScene = EditorSceneManager.GetActiveScene();
            int   instanceID        = editorActiveScene.GetRootGameObjects()[0].GetInstanceID();
            Debug2.Log(instanceID, HierarchyUtil.IsExpanded(editorActiveScene.GetRootGameObjects()[0]));
            RecordSceneToLocal(editorActiveScene);
            break;

        case PlayModeStateChange.EnteredPlayMode:
            //EditorApplication.playModeStateChanged -= OnPlayerModeStateChanged;
            break;

        case PlayModeStateChange.ExitingPlayMode:
            //EditorSceneManager.sceneLoaded -= OnSceneLoaded;
            EditorSceneManager.activeSceneChanged -= OnActiveSceneChanged;
            break;
        }
    }
コード例 #8
0
    public static string[] OnWillSaveAssets(string[] paths)
    {
        // Get the name of the scene to save.
        string scenePath = string.Empty;
        string sceneName = string.Empty;

        Debug2.Log("SAVING");
        foreach (string path in paths)
        {
            Debug2.Log(" NEXT: ");
            if (path.Contains(".unity"))
            {
                scenePath = Path.GetDirectoryName(path);
                sceneName = Path.GetFileNameWithoutExtension(path);
            }
        }

        if (sceneName.Length == 0)
        {
            return(paths);
        }

        // DO WHAT YOU NEED TO DO HERE.
        // FOR EXAMPLE, CALL A STATIC FUNCTION FROM ANOTHER CLASS
        Debug2.Log("	\nscenePath: "+ scenePath);
        Debug2.Log("	sceneName: "+ sceneName);


        return(paths);
    }
コード例 #9
0
    public override void Init()
    {
        Debug2.Log("init MRUController");
        base.Init();

        if (initOnStart)
        {
            initializeVKApi();
        }
    }
コード例 #10
0
    private static void OnActiveSceneChanged(Scene current, Scene next)
    {
        Debug.Log("== OnActiveSceneChanged:");
        //Debug.Log(next.GetRootGameObjects()[2].name);

        //HierarchyUtil.SetExpandedRecursive(next.GetRootGameObjects()[2],true);

        Scene runtimeActiveScene = UnityEngine.SceneManagement.SceneManager.GetActiveScene();

        Debug2.Log(runtimeActiveScene.GetRootGameObjects()[0].GetInstanceID());
    }
コード例 #11
0
    public XmlElement ToXml(XmlDocument doc)
    {
        var ele = doc.CreateElement("MorphGradient");

        ele.SetAttribute("numGradients", numGradients.ToString());
        Debug2.Log("gradientRecords:", gradientRecords);
        for (var i = 0; i < gradientRecords.Length; i++)
        {
            ele.AppendChild(gradientRecords[i].ToXml(doc));
        }
        return(ele);
    }
コード例 #12
0
    private float getTextureHeightWithXmlNodes(XmlNodeList nodes)
    {
        float result = 0;
        float maxX   = 0;
        float maxY   = 0;

        for (int i = 0; i < nodes.Count; i++)
        {
            XmlElement ele    = nodes[i] as XmlElement;
            float      x      = float.Parse(ele.GetAttribute("x"));
            float      y      = float.Parse(ele.GetAttribute("y"));
            float      width  = float.Parse(ele.GetAttribute("width"));
            float      height = float.Parse(ele.GetAttribute("height"));
            float      x1     = x + width;
            float      y1     = y + height;
            if (x1 > maxX)
            {
                maxX = x1;
            }
            if (y1 > maxY)
            {
                maxY = y1;
            }
        }
        float max = Mathf.Max(maxX, maxY);
        //flash sprite sheet中,
        //以竖向排列优先[占位高度大于某个(2的次方值)则马上放大图表高度缩小宽度进行排列),
        //所以如果占位宽大于占位高图表的高度一定是大于占位宽的(2的次方值)]
        int pow = 5;      //5~13

        while (true)
        {
            float val = 1 << pow;
            pow++;
            if (val > max)
            {
                result = val;
                break;
            }
            else if (pow >= 13)
            {
                result = val;
                break;
            }
        }
        Debug2.Log("textureHeight:" + result, "maxX:" + maxX, "maxY:" + maxY);
        return(result);
    }
コード例 #13
0
	private void simplifyList(List<Vector2> list,int stepCount=3){
		for(int f=0;f<stepCount;f++){
			int i=list.Count;
			while(--i>=0){
				if(i>0){
					Vector2 pt=list[i];
					Vector2 prev=list[i-1];
					float distance=Vector2.Distance(pt,prev);
					distance/=10.0f;
					if(f==2)Debug2.Log(i,distance);
					if(distance<=3.0f){//距离小于3个像素删除
						list.RemoveAt(i);
					}
				}
			}
		}
	}
コード例 #14
0
        public static void PaitCircale(RaycastHit hit, int radius, Color color)
        {
            var anilMaterial = hit.collider.GetComponent <AnilMaterial>();

            if (!anilMaterial)
            {
                return;
            }

            renderer = anilMaterial.renderer;

            texture2D = anilMaterial.texture2D;

            if (!texture2D.isReadable)
            {
                Debug2.Log("texture is not readable");
                return;
            }

            pCoord    = hit.textureCoord;
            pCoord.x *= texture2D.width;
            pCoord.y *= texture2D.height;
            // startPosX
            int x = Mathf.RoundToInt(pCoord.x * renderer.material.mainTextureScale.x);
            // startPosY
            int y = Mathf.RoundToInt(pCoord.y * renderer.material.mainTextureScale.y);

            float rSquared = radius * radius;

            for (int u = x - radius; u < x + radius + 1; u++)
            {
                for (int v = y - radius; v < y + radius + 1; v++)
                {
                    if ((x - u) * (x - u) + (y - v) * (y - v) < rSquared)
                    {
                        texture2D.SetPixel(u, v, color);
                    }
                }
            }

            texture2D.Apply();
            renderer.material.SetTexture(_MainTex, texture2D);
        }
コード例 #15
0
    public static void Main()
    {
        if (EditorApplication.isPlaying)
        {
            return;
        }
        Debug.Log("== Tools/EditScenes ==");

        List <string> scenePaths = new List <string>();

        for (int i = 1; i <= 80; i++)
        {
            scenePaths.Add("Assets/Scenes/Level_" + i + ".unity");
        }

        OpenScenesOneByOne(scenePaths.ToArray(), (Scene scene) => {
            Debug2.Log(scene.name);

            //GameObject gameObj=GameObject.Find("CanvasLevel/PanelLevel/SafeAreaGroup/ButtonShop");
            //获取 Transform 序列化对象
            //RectTransform rt=(RectTransform)gameObj.transform;
            //SerializedObject so=new SerializedObject(rt);

            //遍历查看属性

            /*var prop=so.GetIterator();
             *          while(prop.Next(true)){
             *                  Debug.Log(prop.name);
             *          }*/

            //Revert GameObject or Component
            //PrefabUtility.RevertObjectOverride(rt,InteractionMode.AutomatedAction);

            //Revert a property

            /*SerializedProperty propAnchoredPos=so.FindProperty("m_AnchoredPosition");
             *          PrefabUtility.RevertPropertyOverride(propAnchoredPos,InteractionMode.AutomatedAction);*/

            //修改后,必须标记'已编辑',否则保存场景无效
            //EditorSceneManager.MarkSceneDirty(scene);
        });
    }
コード例 #16
0
ファイル: Math.cs プロジェクト: benanil/AnilTools-Utility
        public static Color RaycastPointColor(RaycastHit hit)
        {
            RointInfo.renderer = hit.collider.GetComponent <MeshRenderer>();
            if (!RointInfo.renderer)
            {
                return(Color.white);
            }

            RointInfo.texture2D = RointInfo.renderer.material.mainTexture as Texture2D;

            if (!RointInfo.texture2D.isReadable)
            {
                Debug2.Log("texture is not readable");
                return(Color.white);
            }

            RointInfo.pCoord    = hit.textureCoord;
            RointInfo.pCoord.x *= RointInfo.texture2D.width;
            RointInfo.pCoord.y *= RointInfo.texture2D.height;
            return(RointInfo.texture2D.GetPixel(Mathf.FloorToInt(RointInfo.pCoord.x * RointInfo.renderer.material.mainTextureScale.x), Mathf.FloorToInt(RointInfo.pCoord.y * RointInfo.renderer.material.mainTextureScale.y)));
        }
コード例 #17
0
        public static void PaitCube(RaycastHit hit, int widthHeight, Color color)
        {
            var anilMaterial = hit.collider.GetComponent <AnilMaterial>();

            if (!anilMaterial)
            {
                return;
            }

            renderer  = anilMaterial.renderer;
            texture2D = anilMaterial.texture2D;

            if (!texture2D.isReadable)
            {
                Debug2.Log("texture is not readable");
                return;
            }

            pCoord    = hit.textureCoord;
            pCoord.x *= texture2D.width;
            pCoord.y *= texture2D.height;
            // startPosX
            int xStart = Mathf.RoundToInt(pCoord.x * renderer.material.mainTextureScale.x);
            // startPosY
            int yStart = Mathf.RoundToInt(pCoord.y * renderer.material.mainTextureScale.y);

            for (int x = -widthHeight / 2; x < widthHeight / 2; x++)
            {
                for (int y = -widthHeight / 2; y < widthHeight / 2; y++)
                {
                    texture2D.SetPixel(xStart + x, yStart + y, color);
                }
            }

            texture2D.Apply();
            renderer.material.SetTexture(_MainTex, texture2D);
        }
コード例 #18
0
 public static void ShowGC()
 {
     Debug2.Log("Garbrage Collection is " + System.GC.CollectionCount(0).ToString() + " Collection");
 }
コード例 #19
0
 public static void ClearGC()
 {
     Debug2.Log("garbrage collected: " + System.GC.CollectionCount(0).ToString(), Color.green);
     System.GC.Collect();
 }
コード例 #20
0
 /// <summary>
 /// 更多游戏
 /// </summary>
 public void MoreGame()
 {
     Debug2.Log("moreGame");
 }