Beispiel #1
0
        public override void OnInspectorGUI()
        {
            GpuBuffer myTarget = (GpuBuffer)target;

            myTarget.BufferSetup = (BufferSetup)EditorGUILayout.ObjectField("Buffer Setup", myTarget.BufferSetup, typeof(BufferSetup), true);
            EditorGUILayout.LabelField("Buffer Info:", EditorStyles.largeLabel);
            if (myTarget.Buffer == null)
            {
                EditorGUILayout.LabelField("Buffer not initialized");
            }
            else
            {
                EditorGUILayout.EnumPopup("Buffer Type", myTarget.BufferType);
                if (myTarget.DataType != null)
                {
                    EditorGUILayout.TextField("Data Type", myTarget.DataType.Name);
                }
                else
                {
                    EditorGUILayout.LabelField("No type");
                }
                EditorGUILayout.IntField("Buffer stride", myTarget.Stride);
                EditorGUILayout.IntField("Buffer count", myTarget.Count);
            }
        }
Beispiel #2
0
        public override void OnInspectorGUI()
        {
            GpuBuffer myTarget = (GpuBuffer)target;

            myTarget.BufferSetup = (BufferSetup)EditorGUILayout.ObjectField("Buffer Setup", myTarget.BufferSetup, typeof(BufferSetup), true);
            EditorGUILayout.LabelField("Buffer Info:", EditorStyles.largeLabel);
            if (myTarget.Buffer == null)
            {
                EditorGUILayout.LabelField("Buffer not initialized");
            }
            else
            {
                EditorGUILayout.EnumPopup("Buffer Type", myTarget.BufferType);
                if (myTarget.DataType != null)
                {
                    EditorGUILayout.TextField("Data Type", myTarget.DataType.Name);
                }
                else
                {
                    EditorGUILayout.LabelField("No type");
                }
                EditorGUILayout.IntField("Buffer stride", myTarget.Stride);
                EditorGUILayout.IntField("Buffer count", myTarget.Count);

                if (GUILayout.Button("Dump Data"))
                {
                    var method     = typeof(GpuBuffer).GetMethod("DumpData");
                    var typeMethod = method.MakeGenericMethod(new[] { myTarget.DataType });
                    var dump       = typeMethod.Invoke(myTarget, new object[] { });
                    Debug.Log(dump);
                }
            }
        }
Beispiel #3
0
        /// <summary>
        /// Initializes the GpuBuffer with the correct DataType and Count, then calls CreateData
        /// </summary>
        public virtual void Setup()
        {
            MyGpuBuffer = GetComponent <GpuBuffer>();
            System.Type ParsedType = System.Type.GetType(DataType);
            if (ParsedType == null)
            {
                Debug.LogError("Failed to parse type '" + DataType + "'!");
            }
            MyGpuBuffer.SetType(ParsedType);
            MyGpuBuffer.SetCount(Count);

            CreateData();
        }