private void OnApplicationStart()
 {
     Utils.Log("OnApplicationStart");
     LOCK_TEXTURE = new Texture2D(2, 2);
     Texture2DUtils.LoadImage(LOCK_TEXTURE, Convert.FromBase64String(LOCK_ICON));
     LOCK_SPRITE     = Sprite.Create(LOCK_TEXTURE, new Rect(0, 0, LOCK_TEXTURE.width, LOCK_TEXTURE.height), new Vector2(0.5f, 0.5f));
     harmonyInstance = HarmonyInstance.Create(ModInfo.Name);
 }
Пример #2
0
        internal static void Init()
        {
            if (Environment.CommandLine.Contains("--vrctools.enablenameplateicons"))
            {
                enableNameplateIcons = true;
            }

            VRCModNetworkManager.SetRPCListener("slaynash.vrctools.moddedplayerlistonjoin", OnModdedplayerlistonjoinReceived);
            VRCModNetworkManager.SetRPCListener("slaynash.vrctools.moddedplayerjoined", OnModdedplayerjoinReceived);
            VRCModNetworkManager.SetRPCListener("slaynash.vrctools.moddedplayerleft", OnModdedplayerleftReceived);

            userProperty = typeof(Player).GetProperties(BindingFlags.Public | BindingFlags.Instance).First((pi) => pi.PropertyType == typeof(APIUser));

            Texture2D tex = new Texture2D(2, 2);

            Texture2DUtils.LoadImage(tex, Convert.FromBase64String(ImageDatas.VRCTOOLS_LOGO));
            vrctoolsSprite = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
        }
Пример #3
0
        public static UIToggleSwitch CreateUIToggleSwitch(RectTransform parent)
        {
            if (toggle_background == null)
            {
                Texture2D tex = new Texture2D(2, 2);
                Texture2DUtils.LoadImage(tex, Convert.FromBase64String(ImageDatas.UI_TOGGLE_BACKGROUND));
                toggle_background = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
            }

            if (toggle_cursor == null)
            {
                Texture2D tex = new Texture2D(2, 2);
                Texture2DUtils.LoadImage(tex, Convert.FromBase64String(ImageDatas.UI_TOGGLE_CURSOR));
                toggle_cursor = Sprite.Create(tex, new Rect(0, 0, tex.width, tex.height), new Vector2(0.5f, 0.5f));
            }

            // Create objects
            GameObject toggleGO = new GameObject("ToggleGO", typeof(RectTransform), typeof(Toggle), typeof(UIToggleSwitch));

            toggleGO.transform.SetParent(parent, false);
            GameObject backgroundGO = new GameObject("background", typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));

            backgroundGO.transform.SetParent(toggleGO.transform, false);
            GameObject fillImageGO = new GameObject("fillImage", typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));

            fillImageGO.transform.SetParent(backgroundGO.transform, false);
            GameObject cursorGO = new GameObject("cursor", typeof(RectTransform), typeof(CanvasRenderer), typeof(Image));

            cursorGO.transform.SetParent(toggleGO.transform, false);

            // Set ToggleGO values
            toggleGO.layer = parent.gameObject.layer;
            toggleGO.GetComponent <Toggle>().interactable = true;
            toggleGO.GetComponent <Toggle>().transition   = Selectable.Transition.None;
            toggleGO.GetComponent <Toggle>().isOn         = false;
            toggleGO.GetComponent <UIToggleSwitch>().backgroundFilling = fillImageGO.GetComponent <Image>();
            toggleGO.GetComponent <UIToggleSwitch>().cursor            = cursorGO.GetComponent <Image>();
            toggleGO.GetComponent <UIToggleSwitch>().switchDuration    = 0.12f;
            toggleGO.GetComponent <RectTransform>().sizeDelta          = new Vector2(134, 60);

            // Set background values
            backgroundGO.layer = toggleGO.layer;
            backgroundGO.GetComponent <Image>().sprite            = toggle_background;
            backgroundGO.GetComponent <Image>().color             = new Color(0, 0.957f, 1);
            backgroundGO.GetComponent <Image>().raycastTarget     = false;
            backgroundGO.GetComponent <RectTransform>().sizeDelta = new Vector2(120, 45);

            // Set fillImage values
            fillImageGO.layer = backgroundGO.layer;
            fillImageGO.GetComponent <Image>().sprite            = toggle_background;
            fillImageGO.GetComponent <Image>().color             = new Color(0, 0.67f, 1);
            fillImageGO.GetComponent <Image>().type              = Image.Type.Filled;
            fillImageGO.GetComponent <Image>().fillMethod        = Image.FillMethod.Horizontal;
            fillImageGO.GetComponent <RectTransform>().sizeDelta = new Vector2(120, 45);

            // Set cursor values
            cursorGO.layer = toggleGO.layer;
            cursorGO.GetComponent <Image>().sprite                   = toggle_cursor;
            cursorGO.GetComponent <Image>().color                    = new Color(0, 0.67f, 1);
            cursorGO.GetComponent <RectTransform>().sizeDelta        = new Vector2(60, 60);
            cursorGO.GetComponent <RectTransform>().anchoredPosition = new Vector2(-37, 0);

            return(toggleGO.GetComponent <UIToggleSwitch>());
        }
Пример #4
0
 void Awake()
 {
     fadeOutTexture = Texture2DUtils.MakeTexture(Color.black);
     GameEvent.OnSceneInitialized += () => FadeIn();
 }