Пример #1
0
        private void LoadConfig()
        {
            PListConfig pListConfig = new PListConfig("Library/ServerPreferences.plist");

            this.serverAddress = pListConfig["Maint Server"];
            this.userName      = pListConfig["Maint UserName"];
            this.port          = pListConfig["Maint port number"];
            this.projectName   = pListConfig["Maint project name"];
            this.password      = ASEditorBackend.GetPassword(this.serverAddress, this.userName);
            if (this.port != string.Empty && this.port != 10733.ToString())
            {
                this.serverAddress = this.serverAddress + ":" + this.port;
            }
            this.serversList         = InternalEditorUtility.GetEditorSettingsList("ASServer", 20);
            this.serversLv.totalRows = this.serversList.Length;
            if (ArrayUtility.Contains <string>(this.serversList, this.serverAddress))
            {
                this.serversLv.row = ArrayUtility.IndexOf <string>(this.serversList, this.serverAddress);
            }
        }
Пример #2
0
        private void DoConnect()
        {
            AssetServer.RemoveMaintErrorsFromConsole();
            int    result        = 0x29ed;
            string serverAddress = this.serverAddress;

            if (serverAddress.IndexOf(":") > 0)
            {
                int.TryParse(serverAddress.Substring(serverAddress.IndexOf(":") + 1), out result);
                serverAddress = serverAddress.Substring(0, serverAddress.IndexOf(":"));
            }
            this.port = result.ToString();
            string str2 = AssetServer.GetDatabaseName(serverAddress, this.userName, this.password, this.port, this.projectName);

            this.GetDefaultPListConfig();
            this.plc["Maint Server"]        = serverAddress;
            this.plc["Maint UserName"]      = this.userName;
            this.plc["Maint database name"] = str2;
            this.plc["Maint port number"]   = this.port;
            this.plc["Maint project name"]  = this.projectName;
            this.plc.Save();
            if (ArrayUtility.Contains <string>(this.serversList, this.serverAddress))
            {
                ArrayUtility.Remove <string>(ref this.serversList, this.serverAddress);
            }
            ArrayUtility.Insert <string>(ref this.serversList, 0, this.serverAddress);
            ASEditorBackend.AddUser(this.serverAddress, this.userName);
            ASEditorBackend.SetPassword(this.serverAddress, this.userName, this.password);
            InternalEditorUtility.SaveEditorSettingsList("ASServer", this.serversList, 20);
            if (str2 != string.Empty)
            {
                ASEditorBackend.InitializeMaintBinding();
                this.parentWin.Reinit();
                GUIUtility.ExitGUI();
            }
            else
            {
                this.parentWin.NeedsSetup = true;
                this.parentWin.Repaint();
            }
        }
Пример #3
0
        internal static void DoBoneHandle(Transform target, Dictionary <Transform, bool> validBones)
        {
            int   id  = target.name.GetHashCode();
            Event evt = Event.current;

            bool hasValidChildBones = false;

            if (validBones != null)
            {
                foreach (Transform child in target)
                {
                    if (validBones.ContainsKey(child))
                    {
                        hasValidChildBones = true;
                        break;
                    }
                }
            }

            Vector3 basePoint = target.position;

            List <Vector3> endPoints = new List <Vector3>();

            // [case 525602] do not draw root.
            if (!hasValidChildBones && target.parent != null)
            {
                endPoints.Add(target.position + (target.position - target.parent.position) * 0.4f);
            }
            else
            {
                foreach (Transform child in target)
                {
                    // Only render bone connections to valid bones
                    // (except if no child bones are valid - then draw all connections)
                    if (validBones != null && !validBones.ContainsKey(child))
                    {
                        continue;
                    }

                    endPoints.Add(child.position);
                }
            }

            for (int i = 0; i < endPoints.Count; i++)
            {
                Vector3 endPoint = endPoints[i];


                switch (evt.GetTypeForControl(id))
                {
                case EventType.Layout:
                {
                    float     len      = Vector3.Magnitude(endPoint - basePoint);
                    float     size     = len * k_BoneThickness;
                    Vector3[] vertices = GetBoneVertices(endPoint, basePoint, size);

                    HandleUtility.AddControl(id, DistanceToPolygone(vertices));

                    break;
                }

                case EventType.MouseMove:
                    if (id == HandleUtility.nearestControl)
                    {
                        HandleUtility.Repaint();
                    }
                    break;

                case EventType.MouseDown:
                {
                    // am I closest to the thingy?
                    if (!evt.alt && HandleUtility.nearestControl == id && evt.button == 0)
                    {
                        GUIUtility.hotControl = id;     // Grab mouse focus
                        if (evt.shift)
                        {
                            Object[] selected = Selection.objects;
                            if (ArrayUtility.Contains(selected, target) == false)
                            {
                                ArrayUtility.Add(ref selected, target);
                                Selection.objects = selected;
                            }
                        }
                        else
                        {
                            Selection.activeObject = target;
                        }

                        EditorGUIUtility.PingObject(target);

                        evt.Use();
                    }
                    break;
                }

                case EventType.MouseDrag:
                {
                    if (!evt.alt && GUIUtility.hotControl == id)
                    {
                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = new UnityEngine.Object[] { target };
                        DragAndDrop.StartDrag(ObjectNames.GetDragAndDropTitle(target));

                        // having a hot control set during drag makes the control eat the drag events
                        // and dragging of bones no longer works over the avatar configure window
                        // see case 912016
                        GUIUtility.hotControl = 0;

                        evt.Use();
                    }
                    break;
                }

                case EventType.MouseUp:
                {
                    if (GUIUtility.hotControl == id && (evt.button == 0 || evt.button == 2))
                    {
                        GUIUtility.hotControl = 0;
                        evt.Use();
                    }
                    break;
                }

                case EventType.Repaint:
                {
                    float len = Vector3.Magnitude(endPoint - basePoint);
                    if (len > 0)
                    {
                        color = GUIUtility.hotControl == 0 && HandleUtility.nearestControl == id ? Handles.preselectionColor : color;

                        // size used to be based on sqrt of length but that makes bones for
                        // huge creatures hair-thin and bones for tiny creatures bulky.
                        // So base on a fixed proportion instead.
                        float size = len * k_BoneThickness;
                        if (hasValidChildBones)
                        {
                            Handles.DrawBone(endPoint, basePoint, size);
                        }
                        else
                        {
                            Handles.SphereHandleCap(id, basePoint, target.rotation, size * .2f, EventType.Repaint);
                        }
                    }
                    break;
                }
                }
            }
        }
Пример #4
0
        internal static void DoBoneHandle(Transform target, Dictionary <Transform, bool> validBones, BoneRenderer renderer)
        {
            int   id  = target.name.GetHashCode();
            Event evt = Event.current;

            bool hasValidChildBones = false;

            if (validBones != null)
            {
                foreach (Transform child in target)
                {
                    if (validBones.ContainsKey(child))
                    {
                        hasValidChildBones = true;
                        break;
                    }
                }
            }

            Vector3 basePoint = target.position;

            List <Vector3> endPoints = new List <Vector3>();

            // [case 525602] do not draw root.
            if (!hasValidChildBones && target.parent != null)
            {
                endPoints.Add(target.position + (target.position - target.parent.position) * 0.4f);
            }
            else
            {
                foreach (Transform child in target)
                {
                    // Only render bone connections to valid bones
                    // (except if no child bones are valid - then draw all connections)
                    if (validBones != null && !validBones.ContainsKey(child))
                    {
                        continue;
                    }

                    endPoints.Add(child.position);
                }
            }

            for (int i = 0; i < endPoints.Count; i++)
            {
                Vector3 endPoint = endPoints[i];


                switch (evt.GetTypeForControl(id))
                {
                case EventType.Layout:
                {
                    // TODO : This is slow and should be revisited prior to exposing bone handles
                    Vector3[] vertices = BoneRenderer.GetBoneWireVertices(basePoint, endPoint);
                    if (vertices != null)
                    {
                        HandleUtility.AddControl(id, DistanceToPolygone(vertices));
                    }

                    break;
                }

                case EventType.MouseMove:
                    if (id == HandleUtility.nearestControl)
                    {
                        HandleUtility.Repaint();
                    }
                    break;

                case EventType.MouseDown:
                {
                    // am I closest to the thingy?
                    if (!evt.alt && HandleUtility.nearestControl == id && evt.button == 0)
                    {
                        GUIUtility.hotControl = id;     // Grab mouse focus
                        if (evt.shift)
                        {
                            Object[] selected = Selection.objects;
                            if (ArrayUtility.Contains(selected, target) == false)
                            {
                                ArrayUtility.Add(ref selected, target);
                                Selection.objects = selected;
                            }
                        }
                        else
                        {
                            Selection.activeObject = target;
                        }

                        EditorGUIUtility.PingObject(target);

                        evt.Use();
                    }
                    break;
                }

                case EventType.MouseDrag:
                {
                    if (!evt.alt && GUIUtility.hotControl == id)
                    {
                        DragAndDrop.PrepareStartDrag();
                        DragAndDrop.objectReferences = new UnityEngine.Object[] { target };
                        DragAndDrop.StartDrag(ObjectNames.GetDragAndDropTitle(target));

                        // having a hot control set during drag makes the control eat the drag events
                        // and dragging of bones no longer works over the avatar configure window
                        // see case 912016
                        GUIUtility.hotControl = 0;

                        evt.Use();
                    }
                    break;
                }

                case EventType.MouseUp:
                {
                    if (GUIUtility.hotControl == id && (evt.button == 0 || evt.button == 2))
                    {
                        GUIUtility.hotControl = 0;
                        evt.Use();
                    }
                    break;
                }

                case EventType.Repaint:
                {
                    color = GUIUtility.hotControl == 0 && HandleUtility.nearestControl == id ? Handles.preselectionColor : color;
                    if (hasValidChildBones)
                    {
                        renderer.AddBoneInstance(basePoint, endPoint, color);
                    }
                    else
                    {
                        renderer.AddBoneLeafInstance(basePoint, target.rotation, (endPoint - basePoint).magnitude, color);
                    }
                }
                break;
                }
            }
        }