Esempio n. 1
0
        /// <summary>
        /// 禁用网卡。需要管理员权限运行
        /// </summary>
        /// <returns></returns>
        public Boolean Disable()
        {
            if (ManageObject == null)
            {
                throw new ApplicationException("未设置的ManagementObject对象");
            }

            try
            {
                object result = ManageObject.InvokeMethod("Disable", null);

                UInt32 r = UInt32.Parse(result.ToString());
                if (r == 0)
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            catch (Exception ex)
            {
                throw new ApplicationException("禁用网卡失败。", ex);
            }
        }
Esempio n. 2
0
    // Use this for initialization
    void Start()
    {
        editorPanel = GameObject.Find ("EditPanel").GetComponent<Animator> ();
        editorPanel.enabled = false;
        myflycam = GameObject.Find ("FlyCam").GetComponent("FlyCamScript") as FlyCamScript;
        objectManager = GameObject.Find ("ObjectManager").GetComponent ("ManageObject") as ManageObject;
        editPanelManager = GameObject.Find ("EditorManager").GetComponent ("manageEditPanel") as manageEditPanel;
        realColor = Color.white;

        if (this.transform.parent != null) {
            myObject = transform.parent.gameObject;
        //			myObject.tag = "2D";
                } else {
            myObject = this.gameObject;
        //			myObject.tag = "3D";
                }
    }
        private void OnGUI()
        {
            if (Selection.gameObjects.Length > 0)
            {
                currentSelection = Selection.gameObjects;
            }
            else
            {
                currentSelection = new GameObject[0];
            }

            if (Selection.gameObjects.Length > 0)
            {
                isSelectionPersistent = EditorUtility.IsPersistent(Selection.activeGameObject);
            }
            else
            {
                isSelectionPersistent = false;
            }

            if (replacementObject != null)
            {
                isReplacementPersistent = EditorUtility.IsPersistent(replacementObject);
            }
            else
            {
                isReplacementPersistent = true;
            }

            scrollView = EditorGUILayout.BeginScrollView(scrollView);

            GUILayout.Label("Select a GameObject from the Scene or Hierarchy... ");
            EditorGUILayout.Separator();
            GUILayout.BeginHorizontal();
            objectName = EditorGUILayout.TextField(new GUIContent("Search", "Search for, and select all objects by name."), objectName);
            if (objectName == string.Empty)
            {
                GUI.enabled = false;
            }
            if (GUILayout.Button("Find and Select"))
            {
                List <GameObject> objectsToSelect = new List <GameObject>();
                foreach (GameObject go in FindObjectsOfType <GameObject>())
                {
                    if (go.name == objectName)
                    {
                        objectsToSelect.Add(go);
                    }
                }
                if (objectsToSelect.Count > 0)
                {
                    Selection.objects = objectsToSelect.ToArray();
                }
            }
            GUI.enabled = true;
            GUILayout.EndHorizontal();
            EditorGUILayout.Separator();
            manageObject        = (ManageObject)EditorGUILayout.EnumPopup(new GUIContent("Function", "The selection can either be replaced by the Replacement Object, or the Replacement Object be added without removing the selection from the scene."), manageObject);
            hierarchyParameters = (HierarchyParameters)EditorGUILayout.EnumPopup(new GUIContent("Hierarchy Parameters", "Optional Parameters for retention of Hierarchy status."), hierarchyParameters);
            replacementObject   = EditorGUILayout.ObjectField(new GUIContent("Replacement Object", "The object that will replace the current selection."), replacementObject, typeof(GameObject), true) as GameObject;

            if (manageObject == ManageObject.Add)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
                numberToAdd = 1;
            }

            numberToAdd = EditorGUILayout.IntField(new GUIContent("Number to Add", "The number of times the object will be instantiated at each selection."), (int)Mathf.Clamp(numberToAdd, 1, Mathf.Infinity));
            GUI.enabled = true;
            GUILayout.Label("Maintain Transform");
            EditorGUILayout.BeginHorizontal();
            maintainPosition = GUILayout.Toggle(maintainPosition, new GUIContent("Position", "Will the Replacement Object inherit the currently selected object's position?"));
            maintainRotation = GUILayout.Toggle(maintainRotation, new GUIContent("Rotation", "Will the Replacement Object inherit the currently selected object's rotation?"));
            maintainScale    = GUILayout.Toggle(maintainScale, new GUIContent("Scale", "Will the Replacement Object inherit the currently selected object's scale?"));
            EditorGUILayout.EndHorizontal();
            offset = EditorGUILayout.Foldout(offset, new GUIContent("Offset Transform", "Manually define the offset values of the replacement transform."));

            if (offset)
            {
                offsetPosition = EditorGUILayout.Vector3Field("Position", offsetPosition);
                offsetRotation = EditorGUILayout.Vector3Field("Rotation", offsetRotation);
                offsetScale    = EditorGUILayout.Vector3Field("Scale", offsetScale);
            }

            if (Selection.gameObjects.Length > 0 && !isSelectionPersistent && replacementObject != null && isReplacementPersistent)
            {
                GUI.enabled = true;
            }
            else
            {
                GUI.enabled = false;
            }

            if (manageObject == ManageObject.Add && hierarchyParameters != HierarchyParameters.None && numberToAdd > 1)
            {
                GUI.enabled = false;
            }

            EditorGUILayout.Separator();
            if (GUILayout.Button(manageObject + " Selection"))
            {
                Replace();
            }

            GUI.enabled = true;

            if (Selection.gameObjects.Length == 0)
            {
                EditorGUILayout.HelpBox("No Object Selected.", MessageType.Error, true);
            }
            else if (replacementObject == null)
            {
                EditorGUILayout.HelpBox("No Replacement Object was Assigned.", MessageType.Error, true);
            }
            else if (!isReplacementPersistent)
            {
                EditorGUILayout.HelpBox("Replacement Object must be added from the Project Window.", MessageType.Error, true);
            }
            else if (isSelectionPersistent)
            {
                EditorGUILayout.HelpBox("Selection must be made from the Scene or Hierarchy Window.", MessageType.Error, true);
            }
            else if (manageObject == ManageObject.Add && hierarchyParameters != HierarchyParameters.None && numberToAdd > 1)
            {
                EditorGUILayout.HelpBox("Hierarchy Parameters are only available if 'Number to Add' is equal to one.", MessageType.Error, true);
            }

            EditorGUILayout.EndScrollView();
        }