コード例 #1
0
        public bool     VerifyComponentsReady(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> globalRefs, PrefabConstruct prefab, Client client)
        {
            bool verified = true;

            if (this.gameObject.components == null)
            {
                this.gameObject.RequestComponents(client, go =>
                {
                    this.ConstructComponents(hierarchy, globalRefs, prefab);
                    Utility.RepaintEditorWindow(typeof(NGRemoteWindow));
                });

                verified = false;
            }
            else if (this.components == null)
            {
                this.ConstructComponents(hierarchy, globalRefs, prefab);
            }

            for (int i = 0; i < this.children.Length; i++)
            {
                if (this.children[i].VerifyComponentsReady(hierarchy, globalRefs, prefab, client) == false)
                {
                    verified = false;
                }
            }

            return(verified);
        }
コード例 #2
0
ファイル: ImportAssetsWindow.cs プロジェクト: Hengle/clapotis
 public static void      Open(NGRemoteHierarchyWindow hierarchy)
 {
     Utility.OpenWindow <ImportAssetsWindow>(true, ImportAssetsWindow.Title, true, null, window =>
     {
         window.SetHierarchy(hierarchy);
     });
 }
コード例 #3
0
ファイル: PrefabComponent.cs プロジェクト: Hengle/clapotis
        public PrefabComponent(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> existingRefs, PrefabConstruct prefab, ClientComponent component)
        {
            this.component = component;

            for (int i = 0; i < this.component.fields.Length; i++)
            {
                PrefabField field = this.FetchUnityObjectReferences(hierarchy, existingRefs, prefab, this.component.fields[i].name, this.component.fields[i].value);

                if (field != null)
                {
                    field.UpdateIsSupported();
                    if (field.isSupported == true)
                    {
                        this.hasImportableAssets = true;
                    }

                    PrefabComponent.pool.Add(field);
                }
            }

            if (PrefabComponent.pool.Count > 0)
            {
                this.fields = PrefabComponent.pool.ToArray();
                PrefabComponent.pool.Clear();
            }
        }
コード例 #4
0
        public static void      Init(NGRemoteHierarchyWindow hierarchy, Type type, string valuePath, Func <string, byte[], Packet> packetGenerator, Action <ResponsePacket> onPacketComplete, int initialInstanceID)
        {
            ResourcesPickerWindow picker = EditorWindow.GetWindow <ResourcesPickerWindow>(true, "Select " + type.Name);

            picker.hierarchy = hierarchy;
            picker.hierarchy.ResourcesUpdated += picker.RefreshResources;
            picker.type               = type;
            picker.valuePath          = valuePath;
            picker.packetGenerator    = packetGenerator;
            picker.onPacketComplete   = onPacketComplete;
            picker.searchString       = string.Empty;
            picker.selectedInstanceID = 0;
            picker.filteredResources.Clear();
            picker.filteredResourceIDs.Clear();
            picker.initialInstanceID  = initialInstanceID;
            picker.selectedInstanceID = initialInstanceID;
            picker.typeHandler        = TypeHandlersManager.GetTypeHandler(type);
            picker.SetTab(0);
            picker.tabs.Clear();

            foreach (Type t in Utility.EachNGTSubClassesOf(typeof(TabModule), (Type t) =>
            {
                TabModuleForTypeAttribute[]     attributes = t.GetCustomAttributes(typeof(TabModuleForTypeAttribute), false) as TabModuleForTypeAttribute[];

                return(attributes.Length > 0 && type.IsAssignableFrom(attributes[0].type));
            }))
            {
                picker.tabs.Add(Activator.CreateInstance(t, new object[] { picker }) as TabModule);
            }
        }
コード例 #5
0
ファイル: PrefabComponent.cs プロジェクト: Hengle/clapotis
        public void     DrawComponent(Rect r, ImportAssetsWindow importAssets, NGRemoteHierarchyWindow hierarchy)
        {
            r.height  = Constants.SingleLineHeight;
            this.open = EditorGUI.Foldout(r, this.open, this.component.name, false);

            if (this.open == true)
            {
                r.y += r.height;

                if (hierarchy.displayNonSuppported == true || this.hasImportableAssets == true)
                {
                    ++EditorGUI.indentLevel;
                    for (int i = 0; i < this.fields.Length; i++)
                    {
                        r.height = this.fields[i].GetHeight(importAssets, hierarchy);
                        this.fields[i].DrawField(r, importAssets, hierarchy);
                        r.y += r.height;
                    }
                    --EditorGUI.indentLevel;
                }
                else
                {
                    r.xMin  += 5F;
                    r.xMax  -= 5F;
                    r.height = 24F;
                    EditorGUI.HelpBox(r, "Does not contain importable assets.", MessageType.Info);
                }
            }
        }
コード例 #6
0
        public override void    OnGUI()
        {
            if (this.buttonLeft == null)
            {
                this.buttonLeft  = "ButtonLeft";
                this.buttonRight = "ButtonRight";
            }

            if (this.displayOnlyIcon == true)
            {
                if (GUILayout.Button(this.unityModeIcon, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(24F)) == true)
                {
                    NGRemoteHierarchyWindow.FocusUnityWindows();
                }
                Rect r = GUILayoutUtility.GetLastRect();

                GUI.DrawTexture(r, this.unityModeIcon.image, ScaleMode.ScaleToFit);

                if (GUILayout.Button(this.remoteModeIcon, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height), GUILayoutOptionPool.Width(24F)) == true)
                {
                    foreach (NGRemoteHierarchyWindow window in Utility.EachEditorWindows(typeof(NGRemoteHierarchyWindow)))
                    {
                        window.Focus();
                    }

                    foreach (NGRemoteWindow window in Utility.EachEditorWindows(typeof(NGRemoteWindow)))
                    {
                        window.Focus();
                    }
                }

                r = GUILayoutUtility.GetLastRect();

                GUI.DrawTexture(r, this.remoteModeIcon.image, ScaleMode.ScaleToFit);
            }
            else
            {
                if (GUILayout.Button(this.unityMode, this.buttonLeft, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    NGRemoteHierarchyWindow.FocusUnityWindows();
                }

                if (GUILayout.Button(this.remoteMode, this.buttonRight, GUILayoutOptionPool.Height(this.hub.height)) == true)
                {
                    foreach (NGRemoteHierarchyWindow window in Utility.EachEditorWindows(typeof(NGRemoteHierarchyWindow)))
                    {
                        window.Focus();
                    }

                    foreach (NGRemoteWindow window in Utility.EachEditorWindows(typeof(NGRemoteWindow)))
                    {
                        window.Focus();
                    }
                }
            }
        }
コード例 #7
0
ファイル: PrefabComponent.cs プロジェクト: Hengle/clapotis
        public float    GetHeight(ImportAssetsWindow importAssets, NGRemoteHierarchyWindow hierarchy)
        {
            float height = Constants.SingleLineHeight;

            for (int i = 0; i < this.fields.Length; i++)
            {
                height += this.fields[i].GetHeight(importAssets, hierarchy);
            }

            return(height);
        }
コード例 #8
0
 public AssetImportParameters(NGRemoteHierarchyWindow hierarchy, string path, Type type, int gameObjectInstanceID, int componentInstanceID, int instanceID, bool isSupported, Object localAsset)
 {
     this.hierarchy = hierarchy;
     this.originPath.Add(new MyClass()
     {
         gameObjectInstanceID = gameObjectInstanceID, componentInstanceID = componentInstanceID, path = path
     });
     this.type       = type;
     this.instanceID = instanceID;
     //this.gameObjectInstanceID = gameObjectInstanceID;
     this.isSupported         = isSupported;
     this.parametersConfirmed = isSupported == false || localAsset != null;
     this.localAsset          = localAsset;
 }
コード例 #9
0
ファイル: NGRemoteWindow.cs プロジェクト: Hengle/clapotis
        protected virtual void  OnGUIDisconnected()
        {
            GUILayout.FlexibleSpace();

            if (GUILayout.Button(LC.G("NGRemote_NotConnected") + Environment.NewLine + LC.G("NGRemote_NotConnectedTooltip"), GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue))
            {
                XGUIHighlightManager.Highlight(NGRemoteHierarchyWindow.NormalTitle + ".Connect");
                NGRemoteHierarchyWindow.Open();
            }

            EditorGUIUtility.AddCursorRect(GUILayoutUtility.GetLastRect(), MouseCursor.Link);

            GUILayout.FlexibleSpace();
        }
コード例 #10
0
        private void    ConstructComponents(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> globalRefs, PrefabConstruct prefab)
        {
            for (int i = 0; i < this.gameObject.components.Count; i++)
            {
                PrefabComponent component = new PrefabComponent(hierarchy, globalRefs, prefab, this.gameObject.components[i]);

                if (component.fields != null)
                {
                    PrefabGameObject.pool.Add(component);
                }
            }

            this.components = PrefabGameObject.pool.ToArray();
            PrefabGameObject.pool.Clear();
        }
コード例 #11
0
ファイル: NGRemoteWindow.cs プロジェクト: Hengle/clapotis
        public void     SetHierarchy(NGRemoteHierarchyWindow hierarchy)
        {
            if (this.hierarchy == hierarchy)
            {
                return;
            }

            if (this.hierarchy != null)
            {
                this.hierarchy.RemoveRemoteWindow(this);
                this.OnHierarchyUninit();
            }

            this.hierarchy = hierarchy;

            if (this.hierarchy != null)
            {
                this.hierarchy.AddRemoteWindow(this);
                this.OnHierarchyInit();
            }
        }
コード例 #12
0
        public override void    OnGUIModule(Rect r, NGRemoteHierarchyWindow hierarchy)
        {
            using (LabelWidthRestorer.Get(110F))
            {
                r.height = Constants.SingleLineHeight;
                EditorGUI.BeginChangeCheck();
                this.useJPG = EditorGUI.Toggle(r, "Use JPG", this.useJPG);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseJPGKeyPref, this.useJPG, true);

                    if (hierarchy.IsClientConnected() == true)
                    {
                        hierarchy.Client.AddPacket(new ClientModuleSetUseJPGPacket(this.useJPG));
                    }
                }
                r.y += r.height + 2F;

                EditorGUI.BeginChangeCheck();
                this.useCompression = EditorGUI.Toggle(r, "Use Compression", this.useCompression);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    NGEditorPrefs.SetBool(ScreenshotModuleEditor.UseCompressionKeyPref, this.useCompression, true);

                    if (hierarchy.IsClientConnected() == true)
                    {
                        hierarchy.Client.AddPacket(new ClientModuleSetUseCompressionPacket(this.useCompression));
                    }
                }
                r.y += r.height + 2F;

                EditorGUI.BeginChangeCheck();
                r.width        = 210F;
                this.scaleMode = (ScaleMode)NGEditorGUILayout.EnumPopup(r, "Scale Mode", this.scaleMode);
                if (EditorGUI.EndChangeCheck() == true)
                {
                    NGEditorPrefs.SetInt(ScreenshotModuleEditor.ScaleModeKeyPref, (int)this.scaleMode, true);
                }
            }
        }
コード例 #13
0
        public bool     VerifyComponentsReady(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> globalRefs, Client client)
        {
            if (this.componentsVerified == false)
            {
                this.componentsVerified = this.rootGameObject.VerifyComponentsReady(hierarchy, globalRefs, this, client);
            }
            else if (this.importsConfirmed == false)
            {
                for (int i = 0; i < this.importParameters.Count; i++)
                {
                    if (this.importParameters[i].ParametersConfirmed == false)
                    {
                        return(false);
                    }
                    else
                    {
                        this.importParameters[i].CheckImportState();
                    }
                }

                this.importsConfirmed = true;
            }
            else if (this.assetsReady == false)
            {
                for (int i = 0; i < this.importParameters.Count; i++)
                {
                    ImportAssetState state = this.importParameters[i].CheckImportState();

                    if (state != ImportAssetState.Ready && state != ImportAssetState.DoesNotExist)
                    {
                        return(false);
                    }
                }

                this.assetsReady = true;
            }

            return(this.componentsVerified == true && this.importsConfirmed == true && this.assetsReady == true);
        }
コード例 #14
0
        public static float     GetHeight(NGRemoteHierarchyWindow hierarchy, int instanceID)
        {
            float          height   = ClientMaterial.MaterialTitleHeight + ClientMaterial.ShaderTitleHeight + 2F;                    // Material title + Shader header + Top/Bottom line separator.
            ClientMaterial material = hierarchy.GetMaterial(instanceID);

            if (material != null)
            {
                if (material.properties == null)
                {
                    height += ClientMaterial.ShaderPropertiesNotAvailableMargin + ClientMaterial.ShaderPropertiesNotAvailableHeight + ClientMaterial.ShaderPropertiesNotAvailableMargin;
                }
                else if (material.open == true)
                {
                    int n = 0;

                    for (int j = 0; j < material.properties.Length; j++)
                    {
                        if (material.properties[j].hidden == true)
                        {
                            continue;
                        }

                        if (material.properties[j].type == NGShader.ShaderPropertyType.TexEnv)
                        {
                            n += 3;
                        }
                        else
                        {
                            ++n;
                        }
                    }

                    height += n * (Constants.SingleLineHeight + ClientComponent.Spacing);                     // Properties + Title spacing.
                }
            }

            return(height);
        }
コード例 #15
0
        public float    GetHeight(ImportAssetsWindow importAssetsWindow, NGRemoteHierarchyWindow hierarchy)
        {
            if (hierarchy.displayNonSuppported == false && this.importParameters.isSupported == false)
            {
                return(0F);
            }

            float height = Constants.SingleLineHeight;

            if (importAssetsWindow.selectedField == this)
            {
                height += this.importParameters.GetHeight();
            }

            if (this.children != null)
            {
                for (int i = 0; i < this.children.Count; i++)
                {
                    height += this.children[i].GetHeight(importAssetsWindow, hierarchy);
                }
            }

            return(height);
        }
コード例 #16
0
ファイル: PrefabComponent.cs プロジェクト: Hengle/clapotis
        private PrefabField     FetchUnityObjectReferences(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters> globalRefs, PrefabConstruct prefab, string name, object value)
        {
            UnityObject uo = value as UnityObject;

            if (uo != null)
            {
                if (uo.instanceID == 0)
                {
                    return(null);
                }

                AssetImportParameters importParameters = null;

                // AssetImportParameters must be known in 3 places to be reused: global, prefab & fields.
                for (int i = 0; i < prefab.importParameters.Count; i++)
                {
                    if (prefab.importParameters[i].instanceID == uo.instanceID)
                    {
                        importParameters = prefab.importParameters[i];
                        break;
                    }
                }

                if (importParameters == null)
                {
                    for (int i = 0; i < globalRefs.Count; i++)
                    {
                        if (globalRefs[i].instanceID == uo.instanceID)
                        {
                            importParameters = globalRefs[i];
                            break;
                        }
                    }

                    if (importParameters != null)
                    {
                        prefab.importParameters.Add(importParameters);
                    }
                }

                if (importParameters == null)
                {
                    Debug.Log("C");
                    importParameters = new AssetImportParameters(hierarchy, name, uo.type, this.component.parent.instanceID, this.component.instanceID, uo.instanceID, RemoteUtility.GetImportAssetTypeSupported(uo.type) != null, null)
                    {
                        prefabPath = Path.GetDirectoryName(prefab.path)
                    };
                    prefab.importParameters.Add(importParameters);
                    globalRefs.Add(importParameters);
                }
                else
                {
                    importParameters.originPath.Add(new AssetImportParameters.MyClass()
                    {
                        gameObjectInstanceID = this.component.parent.instanceID, componentInstanceID = this.component.instanceID, path = name
                    });
                }

                return(new PrefabField(name, importParameters));
            }

            ClientClass gc = value as ClientClass;

            if (gc != null)
            {
                PrefabField field = null;

                for (int j = 0; j < gc.fields.Length; j++)
                {
                    PrefabField child = this.FetchUnityObjectReferences(hierarchy, globalRefs, prefab, gc.fields[j].name, gc.fields[j].value);

                    if (child != null)
                    {
                        if (field == null)
                        {
                            field = new PrefabField(name);
                        }
                        field.AddChild(child);
                    }
                }

                return(field);
            }

            ArrayData a = value as ArrayData;

            if (a != null && a.array != null)
            {
                PrefabField field = null;

                for (int j = 0; j < a.array.Length; j++)
                {
                    PrefabField child = this.FetchUnityObjectReferences(hierarchy, globalRefs, prefab, j.ToCachedString(), a.array.GetValue(j));

                    if (child != null)
                    {
                        if (field == null)
                        {
                            field = new PrefabField(name);
                        }
                        field.AddChild(child);
                    }
                }

                return(field);
            }

            return(null);
        }
コード例 #17
0
 public virtual float    GetGUIModuleHeight(NGRemoteHierarchyWindow hierarchy)
 {
     return(0F);
 }
コード例 #18
0
 /// <summary>
 /// Displays GUI to alter module's settings.
 /// </summary>
 /// <param name="r"></param>
 /// <param name="hierarchy"></param>
 public virtual void     OnGUIModule(Rect r, NGRemoteHierarchyWindow hierarchy)
 {
 }
コード例 #19
0
        public void     DrawField(Rect r, ImportAssetsWindow importAssetsWindow, NGRemoteHierarchyWindow hierarchy)
        {
            if (hierarchy.displayNonSuppported == false && this.importParameters.isSupported == false)
            {
                return;
            }

            //Rect	r = GUILayoutUtility.GetRect(0F, Constants.SingleLineHeight);
            float x = r.x;
            float w = r.width;

            r.width  = EditorGUIUtility.labelWidth;
            r.height = Constants.SingleLineHeight;
            if (this.children != null)
            {
                this.open = EditorGUI.Foldout(r, this.open, this.name, false);
            }
            else
            {
                EditorGUI.LabelField(r, this.name);
            }
            r.x += r.width;

            r.width = w - r.width;
            if (Event.current.type == EventType.MouseDown &&
                r.Contains(Event.current.mousePosition) == true)
            {
                importAssetsWindow.selectedField = this;
                importAssetsWindow.Repaint();
            }

            if (this.importParameters.finalized == true)
            {
                if (this.importParameters.finalObject != null)
                {
                    EditorGUI.ObjectField(r, this.importParameters.finalObject, this.importParameters.realType, false);
                }
                else
                {
                    EditorGUI.LabelField(r, "Null");
                }
            }
            else
            {
                if (this.importParameters.isSupported == false)
                {
                    EditorGUI.LabelField(r, "Not supported.");
                }
                else if (this.importParameters.importErrorMessage != null)
                {
                    EditorGUI.HelpBox(r, "Import failed : " + this.importParameters.importErrorMessage, MessageType.Error);
                }
                else if (this.importParameters.ParametersConfirmed == true)
                {
                    if (this.importParameters.totalBytes > 0)
                    {
                        if (importAssetsWindow.selectedField == this)
                        {
                            EditorGUI.LabelField(r, "Downloading");
                        }
                        else
                        {
                            EditorGUI.LabelField(r, "Downloading (" + ((float)this.importParameters.bytesReceived / (float)this.importParameters.totalBytes * 100F).ToString("0.0") + "%)");
                        }

                        importAssetsWindow.Repaint();
                    }
                    else
                    {
                        EditorGUI.LabelField(r, "Waiting");
                    }
                }
                else
                {
                    EditorGUI.LabelField(r, new GUIContent("Need attention /!\\", UtilityResources.WarningIcon));
                }
            }

            if (importAssetsWindow.selectedField == this)
            {
                r.x     = x + 3F;
                r.width = w - 3F;

                Rect r2 = r;
                r2.x     -= 1F;
                r2.width  = 5F;
                r2.height = 1F;
                EditorGUI.DrawRect(r2, Color.green);

                r.height += this.importParameters.GetHeight();

                r2.height = r.height;
                r2.width  = 1F;
                EditorGUI.DrawRect(r2, Color.green);

                r2.width  = 5F;
                r2.y     += r2.height;
                r2.height = 1F;
                EditorGUI.DrawRect(r2, Color.green);

                //r.height = r2.height - Constants.SingleLineHeight;
                r.y += Constants.SingleLineHeight;

                this.importParameters.DrawAssetImportParams(r, importAssetsWindow);
            }

            if (this.open == true)
            {
                r.xMin += 15F;
                r.y    += r.height;

                //++EditorGUI.indentLevel;
                for (int i = 0; i < this.children.Count; i++)
                {
                    r.height = this.children[i].GetHeight(importAssetsWindow, hierarchy);
                    this.children[i].DrawField(r, importAssetsWindow, hierarchy);
                    r.y += r.height;
                }
                //--EditorGUI.indentLevel;
            }
        }
コード例 #20
0
        private static void     DrawVector4(Rect r, NGRemoteHierarchyWindow hierarchy, int materialInstanceID, NetMaterialProperty property)
        {
            Vector4 vector = property.vectorValue;
            float   labelWidth;
            float   controlWidth;

            Utility.CalculSubFieldsWidth(r.width, 44F, 4, out labelWidth, out controlWidth);

            r.width = labelWidth;
            EditorGUI.LabelField(r, Utility.NicifyVariableName(property.name));
            r.x += r.width;

            using (IndentLevelRestorer.Get(0))
                using (LabelWidthRestorer.Get(14F))
                {
                    r.width = controlWidth;

                    EditorGUI.BeginChangeCheck();
                    Single v = EditorGUI.FloatField(r, "X", vector.x);
                    r.x += r.width;
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        vector.x = v;
                        hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p =>
                        {
                            if (p.CheckPacketStatus() == true)
                            {
                                ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);

                                property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4));
                                Utility.RestoreBBuffer(buffer);
                            }
                        });
                    }

                    EditorGUI.BeginChangeCheck();
                    v    = EditorGUI.FloatField(r, "Y", vector.y);
                    r.x += r.width;
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        vector.y = v;
                        hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p =>
                        {
                            if (p.CheckPacketStatus() == true)
                            {
                                ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);

                                property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4));
                                Utility.RestoreBBuffer(buffer);
                            }
                        });
                    }

                    EditorGUI.BeginChangeCheck();
                    v    = EditorGUI.FloatField(r, "Z", vector.z);
                    r.x += r.width;
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        vector.z = v;
                        hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p =>
                        {
                            if (p.CheckPacketStatus() == true)
                            {
                                ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);

                                property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4));
                                Utility.RestoreBBuffer(buffer);
                            }
                        });
                    }

                    EditorGUI.BeginChangeCheck();
                    v = EditorGUI.FloatField(r, "W", vector.w);
                    if (EditorGUI.EndChangeCheck() == true)
                    {
                        vector.w = v;
                        hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(materialInstanceID, property.name, ClientMaterial.vector4Handler.Serialize(vector)), p =>
                        {
                            if (p.CheckPacketStatus() == true)
                            {
                                ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);

                                property.vectorValue = (Vector4)ClientMaterial.vector4Handler.Deserialize(buffer, typeof(Vector4));
                                Utility.RestoreBBuffer(buffer);
                            }
                        });
                    }
                }
        }
コード例 #21
0
ファイル: NGRemoteWindow.cs プロジェクト: Hengle/clapotis
        protected void  OnGUI()
        {
            FreeLicenseOverlay.First(this, NGTools.NGRemoteScene.NGAssemblyInfo.Name + " Pro", NGRemoteWindow.Title + " is exclusive to NG Tools Pro or NG Remote Scene Pro.\n\nFree version is restrained to read-only.");

            if (this.Hierarchy == null)
            {
                NGRemoteHierarchyWindow[] hierarchies = Resources.FindObjectsOfTypeAll <NGRemoteHierarchyWindow>();

                if (hierarchies.Length == 0)
                {
                    if (GUILayout.Button(LC.G("NGRemote_NoHierarchyAvailable"), GeneralStyles.BigCenterText, GUILayoutOptionPool.ExpandHeightTrue) == true)
                    {
                        NGRemoteHierarchyWindow.Open();
                    }
                }
                else if (hierarchies.Length == 1)
                {
                    // Prevents GUI layout warning.
                    EditorApplication.delayCall += () =>
                    {
                        this.SetHierarchy(hierarchies[0]);
                        this.Repaint();
                    };
                }
                else
                {
                    EditorGUILayout.LabelField(LC.G("NGRemote_RequireHierarchy"));

                    string[] hierarchyNames = new string[hierarchies.Length];

                    for (int i = 0; i < hierarchies.Length; i++)
                    {
                        hierarchyNames[i] = hierarchies[i].titleContent.text + ' ' + hierarchies[i].address + ':' + hierarchies[i].port;
                    }

                    EditorGUILayout.BeginHorizontal();
                    {
                        this.hierarchyIndex = EditorGUILayout.Popup(this.hierarchyIndex, hierarchyNames);

                        if (GUILayout.Button(LC.G("Set")) == true)
                        {
                            this.SetHierarchy(hierarchies[this.hierarchyIndex]);
                        }
                    }
                    EditorGUILayout.EndHorizontal();
                }
            }
            else
            {
                this.OnGUIHeader();

                if (this.Hierarchy.IsClientConnected() == false)
                {
                    this.OnGUIDisconnected();
                }
                else
                {
                    this.OnGUIConnected();
                }
            }

            FreeLicenseOverlay.Last(NGTools.NGRemoteScene.NGAssemblyInfo.Name + " Pro");
        }
コード例 #22
0
        public static void      Draw(Rect r, NGRemoteHierarchyWindow hierarchy, int instanceID)
        {
            ClientMaterial material = hierarchy.GetMaterial(instanceID);

            r.height = 1F;
            r.y     += 1F;
            EditorGUI.DrawRect(r, Color.black);
            r.y     -= 1F;
            r.height = ClientMaterial.MaterialTitleHeight;

            r.y += ClientComponent.Spacing;

            if (Event.current.type == EventType.Repaint)
            {
                r.height += r.height;
                EditorGUI.DrawRect(r, NGRemoteInspectorWindow.MaterialHeaderBackgroundColor);
                r.height = ClientMaterial.MaterialTitleHeight;
            }

            if (material != null)
            {
                string[] shaderNames;
                int[]    shaderInstanceIDs;
                float    width = r.width;
                Utility.content.text = LC.G("Change");
                float changeWidth = GUI.skin.button.CalcSize(Utility.content).x;

                hierarchy.GetResources(typeof(Shader), out shaderNames, out shaderInstanceIDs);

                Utility.content.text  = "Material";
                Utility.content.image = UtilityResources.MaterialIcon;
                material.open         = EditorGUI.Foldout(r, material.open, Utility.content, true);
                Utility.content.image = null;

                r.xMin += 85F;
                GUI.Label(r, material.name, GeneralStyles.ComponentName);
                r.xMin -= 85F;
                r.y    += r.height;

                ++EditorGUI.indentLevel;

                r.height = ClientMaterial.ShaderTitleHeight;

                if (shaderNames != null)
                {
                    if (material.selectedShader == -1)
                    {
                        for (int j = 0; j < shaderNames.Length; j++)
                        {
                            if (shaderNames[j].Equals(material.shader) == true)
                            {
                                material.originalShader = j;
                                material.selectedShader = j;
                                break;
                            }
                        }
                    }

                    r.width -= changeWidth;
                    r.xMin  += 11F;
                    using (LabelWidthRestorer.Get(75F))
                        material.selectedShader = EditorGUI.Popup(r, "Shader", material.selectedShader, shaderNames);
                    r.xMin -= 11F;

                    float w = r.width;
                    r.width = 16F;
                    r.x    += 13F;
                    GUI.DrawTexture(r, UtilityResources.ShaderIcon);
                    r.width = w;
                    r.x    += r.width - 13F;

                    r.width = changeWidth;
                    EditorGUI.BeginDisabledGroup(material.originalShader == material.selectedShader);
                    if (GUI.Button(r, LC.G("Change")) == true)
                    {
                        hierarchy.AddPacket(new ClientChangeMaterialShaderPacket(instanceID, shaderInstanceIDs[material.selectedShader]), p =>
                        {
                            if (p.CheckPacketStatus() == true)
                            {
                                material.Reset((p as ServerSendMaterialDataPacket).netMaterial);
                            }
                        });
                    }
                    EditorGUI.EndDisabledGroup();

                    r.x     = 0F;
                    r.width = width;
                }
                else
                {
                    EditorGUI.LabelField(r, "Shader", LC.G("NGInspector_NotAvailableYet"));

                    if (hierarchy.IsChannelBlocked(typeof(Shader).GetHashCode()) == true)
                    {
                        GUILayout.Label(GeneralStyles.StatusWheel, GUILayoutOptionPool.Width(20F));
                    }
                }

                r.y += r.height;

                r.height = 1F;
                r.y     += 1F;
                EditorGUI.DrawRect(r, Color.gray);
                r.y += 1F;

                if (material.properties == null)
                {
                    r.y     += ClientMaterial.ShaderPropertiesNotAvailableMargin;
                    r.height = ClientMaterial.ShaderPropertiesNotAvailableHeight;
                    r.xMin  += 5F;
                    r.xMax  -= 5F;
                    EditorGUI.HelpBox(r, "Shader properties are not available. (NG Server Scene requires to scan & save shaders!)", MessageType.Info);
                    --EditorGUI.indentLevel;
                    return;
                }

                if (material.open == false)
                {
                    --EditorGUI.indentLevel;
                    return;
                }

                r.height = Constants.SingleLineHeight;

                for (int j = 0; j < material.properties.Length; j++)
                {
                    NetMaterialProperty properties = material.properties[j];

                    if (properties.hidden == true)
                    {
                        continue;
                    }

                    if (properties.type == NGShader.ShaderPropertyType.Color)
                    {
                        EditorGUI.BeginChangeCheck();
                        Color newValue = EditorGUI.ColorField(r, properties.displayName, properties.colorValue);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(instanceID, properties.name, ClientMaterial.colorHandler.Serialize(newValue)), p =>
                            {
                                if (p.CheckPacketStatus() == true)
                                {
                                    ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);

                                    properties.colorValue = (Color)ClientMaterial.colorHandler.Deserialize(buffer, typeof(Color));
                                    Utility.RestoreBBuffer(buffer);
                                }
                            });
                        }
                    }
                    else if (properties.type == NGShader.ShaderPropertyType.Float)
                    {
                        EditorGUI.BeginChangeCheck();
                        float newValue = EditorGUI.FloatField(r, properties.displayName, properties.floatValue);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(instanceID, properties.name, ClientMaterial.floatHandler.Serialize(newValue)), p =>
                            {
                                if (p.CheckPacketStatus() == true)
                                {
                                    ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);

                                    properties.floatValue = (float)ClientMaterial.floatHandler.Deserialize(buffer, typeof(float));
                                    Utility.RestoreBBuffer(buffer);
                                }
                            });
                        }
                    }
                    else if (properties.type == NGShader.ShaderPropertyType.Range)
                    {
                        EditorGUI.BeginChangeCheck();
                        float newValue = EditorGUI.Slider(r, properties.displayName, properties.floatValue, properties.rangeMin, properties.rangeMax);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(instanceID, properties.name, ClientMaterial.floatHandler.Serialize(newValue)), p =>
                            {
                                if (p.CheckPacketStatus() == true)
                                {
                                    ByteBuffer buffer = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);

                                    properties.floatValue = (float)ClientMaterial.floatHandler.Deserialize(buffer, typeof(float));
                                    Utility.RestoreBBuffer(buffer);
                                }
                            });
                        }
                    }
                    else if (properties.type == NGShader.ShaderPropertyType.TexEnv)
                    {
                        UnityObject unityObject = properties.textureValue;
                        int         controlID   = GUIUtility.GetControlID("NGObjectFieldHash".GetHashCode(), FocusType.Keyboard, r);
                        float       x           = r.x;

                        r.width = UnityObjectDrawer.PickerButtonWidth;
                        r.x     = width - UnityObjectDrawer.PickerButtonWidth;

                        if (Event.current.type == EventType.KeyDown &&
                            Event.current.keyCode == KeyCode.Delete &&
                            GUIUtility.keyboardControl == controlID)
                        {
                            UnityObject nullObject = new UnityObject(unityObject.type, 0);

                            hierarchy.AddPacket(new ClientUpdateMaterialPropertyPacket(instanceID, properties.name, TypeHandlersManager.GetTypeHandler <UnityObject>().Serialize(nullObject.type, nullObject)), p =>
                            {
                                if (p.CheckPacketStatus() == true)
                                {
                                    ByteBuffer buffer          = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);
                                    UnityObject newUnityObject = (UnityObject)TypeHandlersManager.GetTypeHandler <UnityObject>().Deserialize(buffer, typeof(UnityObject));

                                    unityObject.Assign(newUnityObject.type, newUnityObject.gameObjectInstanceID, newUnityObject.instanceID, newUnityObject.name);
                                    Utility.RestoreBBuffer(buffer);
                                }
                            });

                            Event.current.Use();
                        }

                        if (Event.current.type == EventType.MouseDown &&
                            r.Contains(Event.current.mousePosition) == true)
                        {
                            hierarchy.PickupResource(typeof(Texture), instanceID + '.' + properties.name, ClientMaterial.UpdateMaterialTexture, p =>
                            {
                                if (p.CheckPacketStatus() == true)
                                {
                                    ByteBuffer buffer          = Utility.GetBBuffer((p as ServerUpdateMaterialPropertyPacket).rawValue);
                                    UnityObject newUnityObject = (UnityObject)TypeHandlersManager.GetTypeHandler <UnityObject>().Deserialize(buffer, typeof(UnityObject));

                                    properties.textureValue.Assign(newUnityObject.type, newUnityObject.gameObjectInstanceID, newUnityObject.instanceID, newUnityObject.name);
                                    Utility.RestoreBBuffer(buffer);
                                }
                            },
                                                     unityObject.instanceID);
                            Event.current.Use();
                        }

                        r.width = width;
                        r.x     = x;

                        Utility.content.text = properties.displayName;

                        Rect prefixRect = EditorGUI.PrefixLabel(r, Utility.content);

                        if (unityObject.instanceID != 0)
                        {
                            Utility.content.text = unityObject.name + " (" + unityObject.type.Name + ")";
                        }
                        else
                        {
                            Utility.content.text = "None (" + unityObject.type.Name + ")";
                        }

                        if (GUI.Button(prefixRect, GUIContent.none, GUI.skin.label) == true)
                        {
                            GUIUtility.keyboardControl = controlID;
                        }

                        if (Event.current.type == EventType.Repaint)
                        {
                            GeneralStyles.UnityObjectPicker.Draw(prefixRect, Utility.content, controlID);
                        }

                        ++EditorGUI.indentLevel;
                        r.x     = 0F;
                        r.width = width;

                        r.y += r.height + ClientComponent.Spacing;
                        EditorGUI.BeginChangeCheck();
                        Vector2 newValue = EditorGUI.Vector2Field(r, "Tiling", properties.textureScale);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            hierarchy.AddPacket(new ClientUpdateMaterialVector2Packet(instanceID, properties.name, newValue, MaterialVector2Type.Scale), p =>
                            {
                                if (p.CheckPacketStatus() == true)
                                {
                                    properties.textureScale = (p as ServerUpdateMaterialVector2Packet).value;
                                }
                            });
                        }

                        r.y += r.height + ClientComponent.Spacing;
                        EditorGUI.BeginChangeCheck();
                        newValue = EditorGUI.Vector2Field(r, "Offset", properties.textureOffset);
                        if (EditorGUI.EndChangeCheck() == true)
                        {
                            hierarchy.AddPacket(new ClientUpdateMaterialVector2Packet(instanceID, properties.name, newValue, MaterialVector2Type.Offset), p =>
                            {
                                if (p.CheckPacketStatus() == true)
                                {
                                    properties.textureOffset = (p as ServerUpdateMaterialVector2Packet).value;
                                }
                            });
                        }
                        --EditorGUI.indentLevel;

                        r.x     = 0F;
                        r.width = width;
                    }
                    else if (properties.type == NGShader.ShaderPropertyType.Vector)
                    {
                        ClientMaterial.DrawVector4(r, hierarchy, instanceID, properties);
                    }

                    r.y += r.height + ClientComponent.Spacing;
                }

                --EditorGUI.indentLevel;
            }
            else
            {
                if (hierarchy.IsChannelBlocked(instanceID) == true)
                {
                    GUI.Label(r, GeneralStyles.StatusWheel);
                }

                r.xMin  += 16F;
                r.height = ClientMaterial.MaterialTitleHeight;

                Utility.content.text  = "Material";
                Utility.content.image = UtilityResources.MaterialIcon;
                EditorGUI.LabelField(r, Utility.content, new GUIContent(LC.G("NGInspector_NotAvailableYet")));
                Utility.content.image = null;
                r.y += r.height;

                r.height = ClientMaterial.ShaderTitleHeight;
                r.xMin  += 16F;
                EditorGUI.LabelField(r, "Shader", LC.G("NGInspector_NotAvailableYet"));
                r.xMin -= 16F;

                r.width = 16F;
                GUI.DrawTexture(r, UtilityResources.ShaderIcon);
            }
        }
コード例 #23
0
 public static void      Open(NGRemoteHierarchyWindow hierarchy)
 {
     Utility.OpenWindow <PacketsHistoricWindow>(true, PacketsHistoricWindow.Title, true, null, w => w.SetHierarchy(hierarchy));
 }
コード例 #24
0
 public ComponentsBrowserWindow(NGRemoteHierarchyWindow hierarchy, int gameObjectInstanceID)
 {
     this.hierarchy            = hierarchy;
     this.gameObjectInstanceID = gameObjectInstanceID;
 }
コード例 #25
0
 public AssetLocationsWindow(NGRemoteHierarchyWindow hierarchy, List <AssetImportParameters.MyClass> paths)
 {
     this.hierarchy = hierarchy;
     this.paths     = paths;
 }
コード例 #26
0
 public override float   GetGUIModuleHeight(NGRemoteHierarchyWindow hierarchy)
 {
     return(18F * 3F);
 }